From ea13fd3c0ec92c44d56ecc422bf5edea78a10f84 Mon Sep 17 00:00:00 2001 From: debris Date: Mon, 1 Feb 2016 14:48:38 +0100 Subject: [PATCH 01/22] util docs cleanup pt.1 --- util/src/heapsizeof.rs | 2 ++ util/src/lib.rs | 49 +++++++++++++++++++++++++++++++----------- util/src/vector.rs | 38 +------------------------------- 3 files changed, 39 insertions(+), 50 deletions(-) diff --git a/util/src/heapsizeof.rs b/util/src/heapsizeof.rs index c6d4cace4..8dcc53728 100644 --- a/util/src/heapsizeof.rs +++ b/util/src/heapsizeof.rs @@ -1,3 +1,5 @@ +//! Calculates heapsize of util types. + use uint::*; use hash::*; diff --git a/util/src/lib.rs b/util/src/lib.rs index 622fc950b..64cbac662 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -8,30 +8,55 @@ //! Ethcore-util library //! //! ### Rust version: -//! - beta //! - nightly //! //! ### Supported platforms: //! - OSX //! - Linux //! -//! ### Dependencies: -//! - RocksDB 3.13 +//! ### Building: //! -//! ### Dependencies Installation: +//! - Ubuntu 14.04 and later: //! +//! ```bash +//! # install rocksdb +//! add-apt-repository "deb http://ppa.launchpad.net/giskou/librocksdb/ubuntu trusty main" +//! apt-get update +//! apt-get install -y --force-yes librocksdb +//! +//! # install multirust +//! curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes +//! +//! # install nightly and make it default +//! multirust update nightly && multirust default nightly +//! +//! # export rust LIBRARY_PATH +//! export LIBRARY_PATH=/usr/local/lib +//! +//! # download and build parity +//! git clone https://github.com/ethcore/parity +//! cd parity +//! cargo build --release +//! ``` +//! //! - OSX: //! //! ```bash +//! # install rocksdb && multirust +//! brew update //! brew install rocksdb -//! ``` +//! brew install multirust //! -//! - From source: +//! # install nightly and make it default +//! multirust update nightly && multirust default nightly //! -//! ```bash -//! wget https://github.com/facebook/rocksdb/archive/rocksdb-3.13.tar.gz -//! tar xvf rocksdb-3.13.tar.gz && cd rocksdb-rocksdb-3.13 && make shared_lib -//! sudo make install +//! # export rust LIBRARY_PATH +//! export LIBRARY_PATH=/usr/local/lib +//! +//! # download and build parity +//! git clone https://github.com/ethcore/parity +//! cd parity +//! cargo build --release //! ``` extern crate slab; @@ -89,8 +114,7 @@ pub mod triehash; /// TODO [Gav Wood] Please document me pub mod trie; pub mod nibbleslice; -/// TODO [Gav Wood] Please document me -pub mod heapsizeof; +mod heapsizeof; pub mod squeeze; /// TODO [Gav Wood] Please document me pub mod semantic_version; @@ -114,7 +138,6 @@ pub use crypto::*; pub use triehash::*; pub use trie::*; pub use nibbleslice::*; -pub use heapsizeof::*; pub use squeeze::*; pub use semantic_version::*; pub use network::*; diff --git a/util/src/vector.rs b/util/src/vector.rs index 94b5ee70c..b9770e30b 100644 --- a/util/src/vector.rs +++ b/util/src/vector.rs @@ -1,40 +1,4 @@ -//! vector util functions - -use std::ptr; - -/// TODO [debris] Please document me -pub trait InsertSlice { - /// TODO [debris] Please document me - fn insert_slice(&mut self, index: usize, elements: &[T]); -} - -/// based on `insert` function implementation from standard library -impl InsertSlice for Vec { - fn insert_slice(&mut self, index: usize, elements: &[T]) { - let e_len = elements.len(); - if e_len == 0 { - return; - } - - let len = self.len(); - assert!(index <= len); - - // space for the new element - self.reserve(e_len); - - unsafe { - { - let p = self.as_mut_ptr().offset(index as isize); - let ep = elements.as_ptr().offset(0); - // shift everything by e_len, to make space - ptr::copy(p, p.offset(e_len as isize), len - index); - // write new element - ptr::copy(ep, p, e_len); - } - self.set_len(len + e_len); - } - } -} +//! Vector extensions. /// Returns len of prefix shared with elem /// From 6ec672a1a64b8a20dcddf88d15d68357491bdd2f Mon Sep 17 00:00:00 2001 From: debris Date: Mon, 1 Feb 2016 14:58:13 +0100 Subject: [PATCH 02/22] docs for util standard, from_json and common modules --- util/src/common.rs | 2 ++ util/src/from_json.rs | 2 ++ util/src/lib.rs | 3 --- util/src/standard.rs | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/util/src/common.rs b/util/src/common.rs index 0f10a4e97..9cf7a3765 100644 --- a/util/src/common.rs +++ b/util/src/common.rs @@ -1,3 +1,5 @@ +//! Utils common types and macros global reexport. + pub use standard::*; pub use from_json::*; pub use error::*; diff --git a/util/src/from_json.rs b/util/src/from_json.rs index 1d95df691..7319ec8aa 100644 --- a/util/src/from_json.rs +++ b/util/src/from_json.rs @@ -1,3 +1,5 @@ +//! Coversion from json. + use standard::*; #[macro_export] diff --git a/util/src/lib.rs b/util/src/lib.rs index 64cbac662..f422db7c8 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -82,13 +82,10 @@ extern crate serde; #[macro_use] extern crate log as rlog; -/// TODO [Gav Wood] Please document me pub mod standard; #[macro_use] -/// TODO [Gav Wood] Please document me pub mod from_json; #[macro_use] -/// TODO [Gav Wood] Please document me pub mod common; pub mod error; pub mod hash; diff --git a/util/src/standard.rs b/util/src/standard.rs index 873df6cb4..d1589d30a 100644 --- a/util/src/standard.rs +++ b/util/src/standard.rs @@ -1,3 +1,5 @@ +//! Std lib global reexports. + pub use std::io; pub use std::fs; pub use std::str; From 2bddc938af6b3b95ed0a6cf2071fd1ccf948b2e9 Mon Sep 17 00:00:00 2001 From: debris Date: Mon, 1 Feb 2016 15:22:42 +0100 Subject: [PATCH 03/22] util docs --- util/src/crypto.rs | 2 + util/src/io/mod.rs | 76 +++++++++++++-------------- util/src/lib.rs | 12 +---- util/src/math.rs | 4 +- util/src/misc.rs | 2 + util/src/network/mod.rs | 99 ++++++++++++++++++------------------ util/src/semantic_version.rs | 2 + util/src/trie/mod.rs | 2 + 8 files changed, 101 insertions(+), 98 deletions(-) diff --git a/util/src/crypto.rs b/util/src/crypto.rs index 79a952a94..8a56c8827 100644 --- a/util/src/crypto.rs +++ b/util/src/crypto.rs @@ -1,3 +1,5 @@ +//! Ethcore crypto. + use hash::*; use bytes::*; use uint::*; diff --git a/util/src/io/mod.rs b/util/src/io/mod.rs index 1906e7438..3d8dd0109 100644 --- a/util/src/io/mod.rs +++ b/util/src/io/mod.rs @@ -1,41 +1,41 @@ -/// General IO module. -/// -/// Example usage for craeting a network service and adding an IO handler: -/// -/// ```rust -/// extern crate ethcore_util; -/// use ethcore_util::*; -/// -/// struct MyHandler; -/// -/// #[derive(Clone)] -/// struct MyMessage { -/// data: u32 -/// } -/// -/// impl IoHandler for MyHandler { -/// fn initialize(&self, io: &IoContext) { -/// io.register_timer(0, 1000).unwrap(); -/// } -/// -/// fn timeout(&self, _io: &IoContext, timer: TimerToken) { -/// println!("Timeout {}", timer); -/// } -/// -/// fn message(&self, _io: &IoContext, message: &MyMessage) { -/// println!("Message {}", message.data); -/// } -/// } -/// -/// fn main () { -/// let mut service = IoService::::start().expect("Error creating network service"); -/// service.register_handler(Arc::new(MyHandler)).unwrap(); -/// -/// // Wait for quit condition -/// // ... -/// // Drop the service -/// } -/// ``` +//! General IO module. +//! +//! Example usage for craeting a network service and adding an IO handler: +//! +//! ```rust +//! extern crate ethcore_util; +//! use ethcore_util::*; +//! +//! struct MyHandler; +//! +//! #[derive(Clone)] +//! struct MyMessage { +//! data: u32 +//! } +//! +//! impl IoHandler for MyHandler { +//! fn initialize(&self, io: &IoContext) { +//! io.register_timer(0, 1000).unwrap(); +//! } +//! +//! fn timeout(&self, _io: &IoContext, timer: TimerToken) { +//! println!("Timeout {}", timer); +//! } +//! +//! fn message(&self, _io: &IoContext, message: &MyMessage) { +//! println!("Message {}", message.data); +//! } +//! } +//! +//! fn main () { +//! let mut service = IoService::::start().expect("Error creating network service"); +//! service.register_handler(Arc::new(MyHandler)).unwrap(); +//! +//! // Wait for quit condition +//! // ... +//! // Drop the service +//! } +//! ``` mod service; mod worker; diff --git a/util/src/lib.rs b/util/src/lib.rs index f422db7c8..81828dd47 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -92,32 +92,24 @@ pub mod hash; pub mod uint; pub mod bytes; pub mod rlp; -/// TODO [Gav Wood] Please document me pub mod misc; -/// TODO [Gav Wood] Please document me -pub mod json_aid; +mod json_aid; pub mod vector; pub mod sha3; pub mod hashdb; pub mod memorydb; pub mod overlaydb; pub mod journaldb; -/// TODO [Gav Wood] Please document me -pub mod math; +mod math; pub mod chainfilter; -/// TODO [Gav Wood] Please document me pub mod crypto; pub mod triehash; -/// TODO [Gav Wood] Please document me pub mod trie; pub mod nibbleslice; mod heapsizeof; pub mod squeeze; -/// TODO [Gav Wood] Please document me pub mod semantic_version; -/// TODO [Gav Wood] Please document me pub mod io; -/// TODO [Gav Wood] Please document me pub mod network; pub mod log; diff --git a/util/src/math.rs b/util/src/math.rs index c85c4653e..71533ec26 100644 --- a/util/src/math.rs +++ b/util/src/math.rs @@ -1,4 +1,6 @@ -/// log2 +//! Common math functions. + +/// Returns log2. pub fn log2(x: usize) -> u32 { if x <= 1 { return 0; diff --git a/util/src/misc.rs b/util/src/misc.rs index 316e78a11..f0e34d4c9 100644 --- a/util/src/misc.rs +++ b/util/src/misc.rs @@ -1,3 +1,5 @@ +//! Diff misc. + use common::*; #[derive(Debug,Clone,PartialEq,Eq)] diff --git a/util/src/network/mod.rs b/util/src/network/mod.rs index 668cdc8b1..52f6ba382 100644 --- a/util/src/network/mod.rs +++ b/util/src/network/mod.rs @@ -1,52 +1,53 @@ -/// Network and general IO module. -/// Example usage for craeting a network service and adding an IO handler: -/// -/// ```rust -/// extern crate ethcore_util as util; -/// use util::*; -/// -/// struct MyHandler; -/// -/// #[derive(Clone)] -/// struct MyMessage { -/// data: u32 -/// } -/// -/// impl NetworkProtocolHandler for MyHandler { -/// fn initialize(&self, io: &NetworkContext) { -/// io.register_timer(0, 1000); -/// } -/// -/// fn read(&self, io: &NetworkContext, peer: &PeerId, packet_id: u8, data: &[u8]) { -/// println!("Received {} ({} bytes) from {}", packet_id, data.len(), peer); -/// } -/// -/// fn connected(&self, io: &NetworkContext, peer: &PeerId) { -/// println!("Connected {}", peer); -/// } -/// -/// fn disconnected(&self, io: &NetworkContext, peer: &PeerId) { -/// println!("Disconnected {}", peer); -/// } -/// -/// fn timeout(&self, io: &NetworkContext, timer: TimerToken) { -/// println!("Timeout {}", timer); -/// } -/// -/// fn message(&self, io: &NetworkContext, message: &MyMessage) { -/// println!("Message {}", message.data); -/// } -/// } -/// -/// fn main () { -/// let mut service = NetworkService::::start(NetworkConfiguration::new()).expect("Error creating network service"); -/// service.register_protocol(Arc::new(MyHandler), "myproto", &[1u8]); -/// -/// // Wait for quit condition -/// // ... -/// // Drop the service -/// } -/// ``` +//! Network and general IO module. +//! +//! Example usage for craeting a network service and adding an IO handler: +//! +//! ```rust +//! extern crate ethcore_util as util; +//! use util::*; +//! +//! struct MyHandler; +//! +//! #[derive(Clone)] +//! struct MyMessage { +//! data: u32 +//! } +//! +//! impl NetworkProtocolHandler for MyHandler { +//! fn initialize(&self, io: &NetworkContext) { +//! io.register_timer(0, 1000); +//! } +//! +//! fn read(&self, io: &NetworkContext, peer: &PeerId, packet_id: u8, data: &[u8]) { +//! println!("Received {} ({} bytes) from {}", packet_id, data.len(), peer); +//! } +//! +//! fn connected(&self, io: &NetworkContext, peer: &PeerId) { +//! println!("Connected {}", peer); +//! } +//! +//! fn disconnected(&self, io: &NetworkContext, peer: &PeerId) { +//! println!("Disconnected {}", peer); +//! } +//! +//! fn timeout(&self, io: &NetworkContext, timer: TimerToken) { +//! println!("Timeout {}", timer); +//! } +//! +//! fn message(&self, io: &NetworkContext, message: &MyMessage) { +//! println!("Message {}", message.data); +//! } +//! } +//! +//! fn main () { +//! let mut service = NetworkService::::start(NetworkConfiguration::new()).expect("Error creating network service"); +//! service.register_protocol(Arc::new(MyHandler), "myproto", &[1u8]); +//! +//! // Wait for quit condition +//! // ... +//! // Drop the service +//! } +//! ``` mod host; mod connection; mod handshake; diff --git a/util/src/semantic_version.rs b/util/src/semantic_version.rs index 92f6ea376..10cf47eac 100644 --- a/util/src/semantic_version.rs +++ b/util/src/semantic_version.rs @@ -1,3 +1,5 @@ +//! Semantic version formatting and comparing. + /// A version value with strict meaning. Use `to_u32` to convert to a simple integer. /// /// # Example diff --git a/util/src/trie/mod.rs b/util/src/trie/mod.rs index ce796bd15..502a7688d 100644 --- a/util/src/trie/mod.rs +++ b/util/src/trie/mod.rs @@ -1,3 +1,5 @@ +//! Trie interface and implementation. + /// TODO [Gav Wood] Please document me pub mod trietraits; pub mod standardmap; From 09ebc924a613d3cc2888e9dda2e070a82bf9c994 Mon Sep 17 00:00:00 2001 From: debris Date: Mon, 1 Feb 2016 16:03:43 +0100 Subject: [PATCH 04/22] json tests are not run in default configuration, faster travis build, fixed coverage for ethcore-rpc and ethash --- .travis.yml | 28 ++++++++++++++++------------ Cargo.toml | 1 + ethcore/Cargo.toml | 1 - 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14e71fa43..3b1e07eab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,8 @@ matrix: fast_finish: true include: - rust: nightly - env: FEATURES="--features rpc" + env: FEATURES="--features ethcore/json-tests" + env: KCOV_FEATURES="" cache: apt: true directories: @@ -27,30 +28,33 @@ before_script: | sudo apt-get update && sudo apt-get install -y --force-yes librocksdb script: -- cargo build --release --verbose -- cargo test --release -p ethash --verbose -- cargo test --release -p ethcore-util --verbose -- cargo test --release -p ethcore --verbose +- cargo build --release --verbose ${FEATURES} +- cargo test --release -p ethash --verbose ${FEATURES} +- cargo test --release -p ethcore-util --verbose ${FEATURES} +- cargo test --release -p ethcore --verbose ${FEATURES} +- cargo test --release -p ethsync --verbose ${FEATURES} - cargo test --release -p ethcore-rpc --verbose ${FEATURES} -- cargo test --release --verbose ${FEATURES} +- cargo test --release -p parity --verbose ${FEATURES} - cargo bench --no-run ${FEATURES} after_success: | wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && cd ../.. && - cargo test --no-run -p ethcore-util && + cargo test --no-run -p ethcore-util ${KCOV_FEATURES} && + cargo test --no-run -p ethash ${KCOV_FEATURES} && + cargo test --no-run -p ethcore ${KCOV_FEATURES} && + cargo test --no-run -p ethsync ${KCOV_FEATURES} && + cargo test --no-run -p ethcore-rpc ${KCOV_FEATURES} && + cargo test --no-run -p parity ${KCOV_FEATURES} && ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethcore_util-* && - cargo test --no-run -p ethash && ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethash-* && - cargo test --no-run -p ethcore --no-default-features && ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethcore-* && - cargo test --no-run -p ethcore-rpc ${FEATURES} && + ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethsync-* && ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethcore_rpc-* && - cargo test --no-run ${FEATURES} && ./kcov-master/tmp/usr/local/bin/kcov --coveralls-id=${COVERALLS_TOKEN} --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/parity-* && [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && - cargo doc ${FEATURES} --no-deps --verbose -p ethcore -p ethcore-util -p ethcore-rpc -p parity -p ethash -p ethsync && + cargo doc ${KCOV_FEATURES} --no-deps --verbose -p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity && echo '' > target/doc/index.html && pip install --user ghp-import && /home/travis/.local/bin/ghp-import -n target/doc diff --git a/Cargo.toml b/Cargo.toml index 3b45bd162..6766a5b2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ ethsync = { path = "sync" } ethcore-rpc = { path = "rpc", optional = true } [features] +default = ["rpc"] rpc = ["ethcore-rpc"] [[bin]] diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 35fa5df81..2df744686 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -25,7 +25,6 @@ crossbeam = "0.1.5" lazy_static = "0.1" [features] -default = ["json-tests"] jit = ["evmjit"] evm-debug = [] json-tests = [] From 205a1990d6ee7242ba87f3fe232bd9601515d021 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 1 Feb 2016 16:19:59 +0100 Subject: [PATCH 05/22] Update mod.rs --- util/src/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/src/io/mod.rs b/util/src/io/mod.rs index 3d8dd0109..4b53a46ae 100644 --- a/util/src/io/mod.rs +++ b/util/src/io/mod.rs @@ -1,6 +1,6 @@ //! General IO module. //! -//! Example usage for craeting a network service and adding an IO handler: +//! Example usage for creating a network service and adding an IO handler: //! //! ```rust //! extern crate ethcore_util; From 9ec2efb2f3f3d1b712afed0040f3811165fa4ba0 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 1 Feb 2016 16:20:46 +0100 Subject: [PATCH 06/22] Update mod.rs --- util/src/io/mod.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/util/src/io/mod.rs b/util/src/io/mod.rs index 4b53a46ae..f81732ce1 100644 --- a/util/src/io/mod.rs +++ b/util/src/io/mod.rs @@ -13,20 +13,20 @@ //! data: u32 //! } //! -//! impl IoHandler for MyHandler { -//! fn initialize(&self, io: &IoContext) { -//! io.register_timer(0, 1000).unwrap(); -//! } -//! -//! fn timeout(&self, _io: &IoContext, timer: TimerToken) { -//! println!("Timeout {}", timer); -//! } -//! -//! fn message(&self, _io: &IoContext, message: &MyMessage) { -//! println!("Message {}", message.data); -//! } +//! impl IoHandler for MyHandler { +//! fn initialize(&self, io: &IoContext) { +//! io.register_timer(0, 1000).unwrap(); //! } //! +//! fn timeout(&self, _io: &IoContext, timer: TimerToken) { +//! println!("Timeout {}", timer); +//! } +//! +//! fn message(&self, _io: &IoContext, message: &MyMessage) { +//! println!("Message {}", message.data); +//! } +//! } +//! //! fn main () { //! let mut service = IoService::::start().expect("Error creating network service"); //! service.register_handler(Arc::new(MyHandler)).unwrap(); From fdd42ae537113429df57febd45087ec0eb50b478 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 1 Feb 2016 17:57:22 +0100 Subject: [PATCH 07/22] Improve version string. --- util/Cargo.toml | 1 + util/src/lib.rs | 1 + util/src/network/host.rs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/util/Cargo.toml b/util/Cargo.toml index 5f57deca3..3c70df8d6 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -28,3 +28,4 @@ sha3 = { path = "sha3" } serde = "0.6.7" clippy = "0.0.37" json-tests = { path = "json-tests" } +target_info = "0.1.0" \ No newline at end of file diff --git a/util/src/lib.rs b/util/src/lib.rs index 622fc950b..5264cadc6 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -34,6 +34,7 @@ //! sudo make install //! ``` +extern crate target_info; extern crate slab; extern crate rustc_serialize; extern crate mio; diff --git a/util/src/network/host.rs b/util/src/network/host.rs index 95b1e3668..4e0ae6092 100644 --- a/util/src/network/host.rs +++ b/util/src/network/host.rs @@ -7,6 +7,7 @@ use std::ops::*; use mio::*; use mio::tcp::*; use mio::udp::*; +use target_info::Target; use hash::*; use crypto::*; use sha3::Hashable; @@ -280,7 +281,7 @@ impl Host where Message: Send + Sync + Clone { config: config, nonce: H256::random(), protocol_version: 4, - client_version: "parity".to_owned(), + client_version: format!("Parity/{}/{}-{}-{}", env!("CARGO_PKG_VERSION"), Target::arch(), Target::env(), Target::os()), listen_port: 0, capabilities: Vec::new(), }), From 8e66f193d85b3f32ce34e4ac610e23704938ebae Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 01:13:19 +0100 Subject: [PATCH 08/22] fixed env variables --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b1e07eab..4737f81a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,8 @@ matrix: fast_finish: true include: - rust: nightly - env: FEATURES="--features ethcore/json-tests" - env: KCOV_FEATURES="" + - env: FEATURES="--features ethcore/json-tests" + - env: KCOV_FEATURES="" cache: apt: true directories: @@ -62,5 +62,5 @@ after_success: | #git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: - secure: 3sUjNi9mhdL5h1GTm8LONnDN/SYvUHT+WSkMl93h3nYiLCQXk8eZaPS98AS7oOaTsfW4UvnwckVFCFl49ttInsv4cd/TkAxmrJHe6kPyS9/4NWUdmP8BjicbBvL/ioSdXMECMEYzPDLV+I3KhtC2LcB6ceDEl/XwMOJlzbGf7RbtcXGVQgMLqSYY1YKjQA4vbT5nFgIS/sZu3Z9yFgN0GafnihKcizqoHhdJjs/zxmX+qJepnC6o3V6KcFnS7QHhM1JOr85twE6S422UlvNaEb5ovwLPqmOl5+fA+6shbx4AxFTY6E9Iors+OVY/JliFhrqOdCt0i2P1FUHN4kbGZQkf0rphN/ZOI2uKNFTOyXiPvppfo/ZemKmcqkwkqP9+lf5QqYmtE6hsAYagxn49xJZILl8tAYbdqxF5gxa+TEVrfsBFtz/Sv3q8QhKQNPAmjEcKyMatyEreLUIFEpFTGIco8jN4eXeSoLRdJ+Z75ihttfQWhNfUDgNL30iQLy0AgFSsh/cyb5M8y9lxrGDzDTogvaiKGwr/V45sPkcXWCkmOgMdINqBB6ZtdL3bGHdyjmYj+y3btjf3aP11k++BL0fXIaKn25aS/p/9iyGb1FyGCM03o4ZRQ3YhTOvfMRfRGf6nWbaMx9upv8o5ShSdysewhrnh3082r7u896ny1Ho= - secure: 0/FeVvFl3AhBW0TCPoujY9zOAYoUNMlAz3XjC04vlc4Ksfx0lGU3KFi97LlALxMWV0lfwQc7ixSe2vTgQVQuLVSU9XEW40fQgEjJlmLca2RcRx1kfzJDypuWSiCME7MWmLPH0ac4COdTDS1z5WGggv5YB7GQPCzFvcmOOaPYtF29ngCtkyB2HmNkY/W3omHFEk7Si6bsmOSHZiOAhivPl6ixnGpFyTEKPyraMMqPIj5rbEGkzgeLTiXf2ur143n/tnSr8tmP1MfQi9yS8/ONidMqnxUeuLkeNnb82zj9pVJhVXq0xF44WXJ8Za1jm0ByiTakgqpm8Juk822qjvtNulJ1XZW/fyZQZaN1dy3uq5Ud3W8wS9M7VIVl8CoXozzDpIsdPeUAtkAxeHBsZqL1vAH2yC1YJA7HPySMYzCjYqkJ2r62xYk0gXmNXphfU+F/X/rHzHsTMJPONJ54HQwu12m7zVlKIYBGHgEXg/HAM/g4ljUzl6WWR/nHH/tQM8ND/8FpHluJSZJWacq/1QNhVdTq2x6cqws2fs5A7nVpccR9+6RRgYgv6+YS2LxvFzByuZveGGoKif+uMECXN876j40araUqU528Yz9i8bHJlnM3coRBndaLNWByLcUyXCB9r9IUosUu41rr+L2mVzkSDm0GicuNCzqvzYQ9Q6QY4uQ= + - secure: 3sUjNi9mhdL5h1GTm8LONnDN/SYvUHT+WSkMl93h3nYiLCQXk8eZaPS98AS7oOaTsfW4UvnwckVFCFl49ttInsv4cd/TkAxmrJHe6kPyS9/4NWUdmP8BjicbBvL/ioSdXMECMEYzPDLV+I3KhtC2LcB6ceDEl/XwMOJlzbGf7RbtcXGVQgMLqSYY1YKjQA4vbT5nFgIS/sZu3Z9yFgN0GafnihKcizqoHhdJjs/zxmX+qJepnC6o3V6KcFnS7QHhM1JOr85twE6S422UlvNaEb5ovwLPqmOl5+fA+6shbx4AxFTY6E9Iors+OVY/JliFhrqOdCt0i2P1FUHN4kbGZQkf0rphN/ZOI2uKNFTOyXiPvppfo/ZemKmcqkwkqP9+lf5QqYmtE6hsAYagxn49xJZILl8tAYbdqxF5gxa+TEVrfsBFtz/Sv3q8QhKQNPAmjEcKyMatyEreLUIFEpFTGIco8jN4eXeSoLRdJ+Z75ihttfQWhNfUDgNL30iQLy0AgFSsh/cyb5M8y9lxrGDzDTogvaiKGwr/V45sPkcXWCkmOgMdINqBB6ZtdL3bGHdyjmYj+y3btjf3aP11k++BL0fXIaKn25aS/p/9iyGb1FyGCM03o4ZRQ3YhTOvfMRfRGf6nWbaMx9upv8o5ShSdysewhrnh3082r7u896ny1Ho= + - secure: 0/FeVvFl3AhBW0TCPoujY9zOAYoUNMlAz3XjC04vlc4Ksfx0lGU3KFi97LlALxMWV0lfwQc7ixSe2vTgQVQuLVSU9XEW40fQgEjJlmLca2RcRx1kfzJDypuWSiCME7MWmLPH0ac4COdTDS1z5WGggv5YB7GQPCzFvcmOOaPYtF29ngCtkyB2HmNkY/W3omHFEk7Si6bsmOSHZiOAhivPl6ixnGpFyTEKPyraMMqPIj5rbEGkzgeLTiXf2ur143n/tnSr8tmP1MfQi9yS8/ONidMqnxUeuLkeNnb82zj9pVJhVXq0xF44WXJ8Za1jm0ByiTakgqpm8Juk822qjvtNulJ1XZW/fyZQZaN1dy3uq5Ud3W8wS9M7VIVl8CoXozzDpIsdPeUAtkAxeHBsZqL1vAH2yC1YJA7HPySMYzCjYqkJ2r62xYk0gXmNXphfU+F/X/rHzHsTMJPONJ54HQwu12m7zVlKIYBGHgEXg/HAM/g4ljUzl6WWR/nHH/tQM8ND/8FpHluJSZJWacq/1QNhVdTq2x6cqws2fs5A7nVpccR9+6RRgYgv6+YS2LxvFzByuZveGGoKif+uMECXN876j40araUqU528Yz9i8bHJlnM3coRBndaLNWByLcUyXCB9r9IUosUu41rr+L2mVzkSDm0GicuNCzqvzYQ9Q6QY4uQ= From 63950aa1a2fb7caf07182b9b319935b6539110cf Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 01:15:22 +0100 Subject: [PATCH 09/22] fixed travis matrix env --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4737f81a0..845400ec8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,8 @@ matrix: fast_finish: true include: - rust: nightly - - env: FEATURES="--features ethcore/json-tests" - - env: KCOV_FEATURES="" + - env: FEATURES="--features ethcore/json-tests" + - env: KCOV_FEATURES="" cache: apt: true directories: From 21de5562d7afe23a6102120b59c4bf9d9ec2c3d3 Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 01:18:27 +0100 Subject: [PATCH 10/22] another attempt to fix build matrix --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 845400ec8..cc788887a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,7 @@ matrix: fast_finish: true include: - rust: nightly - - env: FEATURES="--features ethcore/json-tests" - - env: KCOV_FEATURES="" + env: FEATURES="--features ethcore/json-tests" KCOV_FEATURES="" cache: apt: true directories: From 54924d14b3cdcbad31df975f7f76b587ed77ef51 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 2 Feb 2016 01:59:14 +0100 Subject: [PATCH 11/22] Include JSONRPC CLI options. Bump version numbers. Update Trie benchmarks. Disable RLP benchmark (@debrid please fix). --- ethcore/Cargo.toml | 2 +- ethcore/src/blockchain.rs | 74 +++++++++++++++++++--------------- ethcore/src/client.rs | 7 +++- parity/main.rs | 23 +++++++---- util/Cargo.toml | 4 +- util/benches/rlp.rs | 3 +- util/benches/trie.rs | 78 ++++++++++++++++++++++++++++++++++++ util/src/trie/standardmap.rs | 24 ++++++++--- 8 files changed, 166 insertions(+), 49 deletions(-) diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 35fa5df81..6b7a69a68 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -3,7 +3,7 @@ description = "Ethcore library" homepage = "http://ethcore.io" license = "GPL-3.0" name = "ethcore" -version = "0.1.0" +version = "0.9.0" authors = ["Ethcore "] [dependencies] diff --git a/ethcore/src/blockchain.rs b/ethcore/src/blockchain.rs index 757e51c59..1dea65ae7 100644 --- a/ethcore/src/blockchain.rs +++ b/ethcore/src/blockchain.rs @@ -129,6 +129,9 @@ struct CacheManager { /// /// **Does not do input data verification.** pub struct BlockChain { + pref_cache_size: usize, + max_cache_size: usize, + best_block: RwLock, // block cache @@ -190,9 +193,7 @@ impl BlockProvider for BlockChain { } } -const COLLECTION_QUEUE_SIZE: usize = 2; -const MIN_CACHE_SIZE: usize = 1; -const MAX_CACHE_SIZE: usize = 1024 * 1024; +const COLLECTION_QUEUE_SIZE: usize = 8; impl BlockChain { /// Create new instance of blockchain from given Genesis @@ -237,6 +238,8 @@ impl BlockChain { (0..COLLECTION_QUEUE_SIZE).foreach(|_| cache_man.cache_usage.push_back(HashSet::new())); let bc = BlockChain { + pref_cache_size: 1 << 14, + max_cache_size: 1 << 20, best_block: RwLock::new(BestBlock::new()), blocks: RwLock::new(HashMap::new()), block_details: RwLock::new(HashMap::new()), @@ -288,6 +291,12 @@ impl BlockChain { bc } + /// Set the cache configuration. + pub fn configure_cache(&mut self, pref_cache_size: usize, max_cache_size: usize) { + self.pref_cache_size = pref_cache_size; + self.max_cache_size = max_cache_size; + } + /// Returns a tree route between `from` and `to`, which is a tuple of: /// /// - a vector of hashes of all blocks, ordered from `from` to `to`. @@ -339,12 +348,12 @@ impl BlockChain { Some(h) => h, None => return None, }; - Some(self._tree_route((&from_details, &from), (&to_details, &to))) + Some(self.tree_route_aux((&from_details, &from), (&to_details, &to))) } /// Similar to `tree_route` function, but can be used to return a route /// between blocks which may not be in database yet. - fn _tree_route(&self, from: (&BlockDetails, &H256), to: (&BlockDetails, &H256)) -> TreeRoute { + fn tree_route_aux(&self, from: (&BlockDetails, &H256), to: (&BlockDetails, &H256)) -> TreeRoute { let mut from_branch = vec![]; let mut to_branch = vec![]; @@ -465,7 +474,7 @@ impl BlockChain { // find the route between old best block and the new one let best_hash = self.best_block_hash(); let best_details = self.block_details(&best_hash).expect("best block hash is invalid!"); - let route = self._tree_route((&best_details, &best_hash), (&details, &hash)); + let route = self.tree_route_aux((&best_details, &best_hash), (&details, &hash)); match route.blocks.len() { // its our parent @@ -581,36 +590,37 @@ impl BlockChain { } /// Ticks our cache system and throws out any old data. - pub fn collect_garbage(&self, force: bool) { - // TODO: check time. - let timeout = true; + pub fn collect_garbage(&self) { + if self.cache_size().total() < self.pref_cache_size { return; } - let t = self.cache_size().total(); - if t < MIN_CACHE_SIZE || (!timeout && (!force || t < MAX_CACHE_SIZE)) { return; } + for _ in 0..COLLECTION_QUEUE_SIZE { + { + let mut cache_man = self.cache_man.write().unwrap(); + let mut blocks = self.blocks.write().unwrap(); + let mut block_details = self.block_details.write().unwrap(); + let mut block_hashes = self.block_hashes.write().unwrap(); + let mut transaction_addresses = self.transaction_addresses.write().unwrap(); + let mut block_logs = self.block_logs.write().unwrap(); + let mut blocks_blooms = self.blocks_blooms.write().unwrap(); - let mut cache_man = self.cache_man.write().unwrap(); - let mut blocks = self.blocks.write().unwrap(); - let mut block_details = self.block_details.write().unwrap(); - let mut block_hashes = self.block_hashes.write().unwrap(); - let mut transaction_addresses = self.transaction_addresses.write().unwrap(); - let mut block_logs = self.block_logs.write().unwrap(); - let mut blocks_blooms = self.blocks_blooms.write().unwrap(); + for id in cache_man.cache_usage.pop_back().unwrap().into_iter() { + cache_man.in_use.remove(&id); + match id { + CacheID::Block(h) => { blocks.remove(&h); }, + CacheID::Extras(ExtrasIndex::BlockDetails, h) => { block_details.remove(&h); }, + CacheID::Extras(ExtrasIndex::TransactionAddress, h) => { transaction_addresses.remove(&h); }, + CacheID::Extras(ExtrasIndex::BlockLogBlooms, h) => { block_logs.remove(&h); }, + CacheID::Extras(ExtrasIndex::BlocksBlooms, h) => { blocks_blooms.remove(&h); }, + _ => panic!(), + } + } + cache_man.cache_usage.push_front(HashSet::new()); - for id in cache_man.cache_usage.pop_back().unwrap().into_iter() { - cache_man.in_use.remove(&id); - match id { - CacheID::Block(h) => { blocks.remove(&h); }, - CacheID::Extras(ExtrasIndex::BlockDetails, h) => { block_details.remove(&h); }, - CacheID::Extras(ExtrasIndex::TransactionAddress, h) => { transaction_addresses.remove(&h); }, - CacheID::Extras(ExtrasIndex::BlockLogBlooms, h) => { block_logs.remove(&h); }, - CacheID::Extras(ExtrasIndex::BlocksBlooms, h) => { blocks_blooms.remove(&h); }, - _ => panic!(), + // TODO: handle block_hashes properly. + block_hashes.clear(); } + if self.cache_size().total() < self.max_cache_size { break; } } - cache_man.cache_usage.push_front(HashSet::new()); - - // TODO: handle block_hashes properly. - block_hashes.clear(); // TODO: m_lastCollection = chrono::system_clock::now(); } @@ -786,7 +796,7 @@ mod tests { assert!(bc.cache_size().blocks > 1024 * 1024); for _ in 0..2 { - bc.collect_garbage(true); + bc.collect_garbage(); } assert!(bc.cache_size().blocks < 1024 * 1024); } diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 1a59aefc5..ee9b658d8 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -294,7 +294,12 @@ impl Client { /// Tick the client. pub fn tick(&self) { - self.chain.read().unwrap().collect_garbage(false); + self.chain.read().unwrap().collect_garbage(); + } + + /// Set up the cache behaviour. + pub fn configure_cache(&self, pref_cache_size: usize, max_cache_size: usize) { + self.chain.write().unwrap().configure_cache(pref_cache_size, max_cache_size); } } diff --git a/parity/main.rs b/parity/main.rs index a9dfe004e..6aec14884 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -35,9 +35,15 @@ Usage: parity [options] ... Options: - -l --logging LOGGING Specify the logging level - -h --help Show this screen. -"); + -l --logging LOGGING Specify the logging level. + -j --jsonrpc Enable the JSON-RPC API sever. + --jsonrpc-url URL Specify URL for JSON-RPC API server (default: 127.0.0.1:8545). + + --cache-pref-size BYTES Specify the prefered size of the blockchain cache in bytes (default: 16384). + --cache-max-size BYTES Specify the maximum size of the blockchain cache in bytes (default: 262144). + + -h --help Show this screen. +", flag_cache_pref_size: usize, flag_cache_max_size: usize); fn setup_log(init: &str) { let mut builder = LogBuilder::new(); @@ -54,7 +60,7 @@ fn setup_log(init: &str) { #[cfg(feature = "rpc")] -fn setup_rpc_server(client: Arc, sync: Arc) { +fn setup_rpc_server(client: Arc, sync: Arc, url: &str) { use rpc::v1::*; let mut server = rpc::HttpServer::new(1); @@ -62,11 +68,11 @@ fn setup_rpc_server(client: Arc, sync: Arc) { server.add_delegate(EthClient::new(client.clone()).to_delegate()); server.add_delegate(EthFilterClient::new(client).to_delegate()); server.add_delegate(NetClient::new(sync).to_delegate()); - server.start_async("127.0.0.1:3030"); + server.start_async(url); } #[cfg(not(feature = "rpc"))] -fn setup_rpc_server(_client: Arc, _sync: Arc) { +fn setup_rpc_server(_client: Arc, _sync: Arc, _url: &str) { } fn main() { @@ -83,8 +89,11 @@ fn main() { net_settings.boot_nodes = init_nodes; let mut service = ClientService::start(spec, net_settings).unwrap(); let client = service.client().clone(); + client.configure_cache(args.flag_cache_pref_size, args.flag_cache_max_size); let sync = EthSync::register(service.network(), client); - setup_rpc_server(service.client(), sync.clone()); + if args.flag_jsonrpc { + setup_rpc_server(service.client(), sync.clone(), &args.flag_jsonrpc_url); + } let io_handler = Arc::new(ClientIoHandler { client: service.client(), info: Default::default(), sync: sync }); service.io().register_handler(io_handler).expect("Error registering IO handler"); diff --git a/util/Cargo.toml b/util/Cargo.toml index 3c70df8d6..a123aecca 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -3,7 +3,7 @@ description = "Ethcore utility library" homepage = "http://ethcore.io" license = "GPL-3.0" name = "ethcore-util" -version = "0.1.0" +version = "0.9.0" authors = ["Ethcore "] [dependencies] @@ -28,4 +28,4 @@ sha3 = { path = "sha3" } serde = "0.6.7" clippy = "0.0.37" json-tests = { path = "json-tests" } -target_info = "0.1.0" \ No newline at end of file +target_info = "0.1.0" diff --git a/util/benches/rlp.rs b/util/benches/rlp.rs index 8bc7599e4..234f7c66d 100644 --- a/util/benches/rlp.rs +++ b/util/benches/rlp.rs @@ -3,7 +3,7 @@ //! ```bash //! multirust run nightly cargo bench //! ``` - +/* #![feature(test)] extern crate test; @@ -94,3 +94,4 @@ fn bench_stream_1000_empty_lists(b: &mut Bencher) { let _ = stream.out(); }); } +*/ \ No newline at end of file diff --git a/util/benches/trie.rs b/util/benches/trie.rs index 5f02b15cf..663663fe3 100644 --- a/util/benches/trie.rs +++ b/util/benches/trie.rs @@ -42,6 +42,84 @@ fn random_value(seed: &mut H256) -> Bytes { } } +#[bench] +fn trie_insertions_32_mir_1k(b: &mut Bencher) { + let st = StandardMap { + alphabet: Alphabet::All, + min_key: 32, + journal_key: 0, + value_mode: ValueMode::Mirror, + count: 1000, + }; + let d = st.make(); + let mut hash_count = 0usize; + b.iter(&mut ||{ + let mut memdb = MemoryDB::new(); + let mut root = H256::new(); + let mut t = TrieDBMut::new(&mut memdb, &mut root); + for i in d.iter() { + t.insert(&i.0, &i.1); + } + hash_count = t.hash_count; + }); +// println!("hash_count: {}", hash_count); +} + +#[bench] +fn triehash_insertions_32_mir_1k(b: &mut Bencher) { + let st = StandardMap { + alphabet: Alphabet::All, + min_key: 32, + journal_key: 0, + value_mode: ValueMode::Mirror, + count: 1000, + }; + let d = st.make(); + b.iter(&mut ||{ + trie_root(d.clone()).clone(); + }); +} + +#[bench] +fn trie_insertions_32_ran_1k(b: &mut Bencher) { + let st = StandardMap { + alphabet: Alphabet::All, + min_key: 32, + journal_key: 0, + value_mode: ValueMode::Random, + count: 1000, + }; + let d = st.make(); + let mut hash_count = 0usize; + let mut r = H256::new(); + b.iter(&mut ||{ + let mut memdb = MemoryDB::new(); + let mut root = H256::new(); + let mut t = TrieDBMut::new(&mut memdb, &mut root); + for i in d.iter() { + t.insert(&i.0, &i.1); + } + hash_count = t.hash_count; + r = t.root().clone(); + }); +// println!("result: {}", hash_count); +} + +#[bench] +fn triehash_insertions_32_ran_1k(b: &mut Bencher) { + let st = StandardMap { + alphabet: Alphabet::All, + min_key: 32, + journal_key: 0, + value_mode: ValueMode::Random, + count: 1000, + }; + let d = st.make(); + b.iter(&mut ||{ + trie_root(d.clone()).clone(); + }); +} + #[bench] fn trie_insertions_six_high(b: &mut Bencher) { let mut d: Vec<(Bytes, Bytes)> = Vec::new(); diff --git a/util/src/trie/standardmap.rs b/util/src/trie/standardmap.rs index 0e65849cc..4573efd66 100644 --- a/util/src/trie/standardmap.rs +++ b/util/src/trie/standardmap.rs @@ -17,12 +17,26 @@ pub enum Alphabet { Custom(Bytes), } +/// Means of determining the value. +pub enum ValueMode { + /// Same as the key. + Mirror, + /// Randomly (50:50) 1 or 32 byte randomly string. + Random, +} + /// Standard test map for profiling tries. pub struct StandardMap { - alphabet: Alphabet, - min_key: usize, - journal_key: usize, - count: usize, + /// The alphabet to use for keys. + pub alphabet: Alphabet, + /// Minimum size of key. + pub min_key: usize, + /// Delta size of key. + pub journal_key: usize, + /// Mode of value generation. + pub value_mode: ValueMode, + /// Number of keys. + pub count: usize, } impl StandardMap { @@ -71,7 +85,7 @@ impl StandardMap { Alphabet::Mid => Self::random_word(mid, self.min_key, self.journal_key, &mut seed), Alphabet::Custom(ref a) => Self::random_word(&a, self.min_key, self.journal_key, &mut seed), }; - let v = Self::random_value(&mut seed); + let v = match self.value_mode { ValueMode::Mirror => k.clone(), ValueMode::Random => Self::random_value(&mut seed) }; d.push((k, v)) } d From baec2909b6eed175a38f60071bea88c589a668c0 Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 02:04:03 +0100 Subject: [PATCH 12/22] added dumb tests for parity and ethcore-rpc to include them in coverage reports, added TARGETS env variable to travis.yml --- .travis.yml | 20 +++++--------------- parity/main.rs | 4 ++++ rpc/src/lib.rs | 5 +++++ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc788887a..d64cf4a9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: fast_finish: true include: - rust: nightly - env: FEATURES="--features ethcore/json-tests" KCOV_FEATURES="" + env: FEATURES="--features ethcore/json-tests" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" cache: apt: true directories: @@ -28,22 +28,12 @@ before_script: | sudo apt-get install -y --force-yes librocksdb script: - cargo build --release --verbose ${FEATURES} -- cargo test --release -p ethash --verbose ${FEATURES} -- cargo test --release -p ethcore-util --verbose ${FEATURES} -- cargo test --release -p ethcore --verbose ${FEATURES} -- cargo test --release -p ethsync --verbose ${FEATURES} -- cargo test --release -p ethcore-rpc --verbose ${FEATURES} -- cargo test --release -p parity --verbose ${FEATURES} -- cargo bench --no-run ${FEATURES} +- cargo test --release --verbose ${FEATURES} ${TARGETS} +- cargo bench --no-run ${FEATURES} ${TARGETS} after_success: | wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && cd ../.. && - cargo test --no-run -p ethcore-util ${KCOV_FEATURES} && - cargo test --no-run -p ethash ${KCOV_FEATURES} && - cargo test --no-run -p ethcore ${KCOV_FEATURES} && - cargo test --no-run -p ethsync ${KCOV_FEATURES} && - cargo test --no-run -p ethcore-rpc ${KCOV_FEATURES} && - cargo test --no-run -p parity ${KCOV_FEATURES} && + cargo test --no-run ${KCOV_FEATURES} ${TARGETS} && ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethcore_util-* && ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethash-* && ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethcore-* && @@ -53,7 +43,7 @@ after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && - cargo doc ${KCOV_FEATURES} --no-deps --verbose -p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity && + cargo doc --no-deps --verbose ${KCOV_FEATURES} ${RARGETS} && echo '' > target/doc/index.html && pip install --user ghp-import && /home/travis/.local/bin/ghp-import -n target/doc diff --git a/parity/main.rs b/parity/main.rs index a9dfe004e..a120f7272 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -169,3 +169,7 @@ impl IoHandler for ClientIoHandler { } } +/// Parity needs at least 1 test to generate coverage reports correctly. +#[test] +fn if_works() { +} diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index fa24694f4..f81e65551 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -42,3 +42,8 @@ impl HttpServer { server.start_async(addr) } } + +/// Lib needs at least 1 test to generate coverage reports correctly. +#[test] +fn if_works() { +} From 26652a2ed891f7e4847ae7cf2270b50c16a53930 Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 02:31:17 +0100 Subject: [PATCH 13/22] fixed rlp benchmarks --- util/benches/rlp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/benches/rlp.rs b/util/benches/rlp.rs index 8bc7599e4..e322143f7 100644 --- a/util/benches/rlp.rs +++ b/util/benches/rlp.rs @@ -63,9 +63,9 @@ fn bench_stream_nested_empty_lists(b: &mut Bencher) { b.iter(|| { // [ [], [[]], [ [], [[]] ] ] let mut stream = RlpStream::new_list(3); - stream.append_list(0); - stream.append_list(1).append_list(0); - stream.append_list(2).append_list(0).append_list(1).append_list(0); + stream.begin_list(0); + stream.begin_list(1).begin_list(0); + stream.begin_list(2).begin_list(0).begin_list(1).begin_list(0); let _ = stream.out(); }); } @@ -89,7 +89,7 @@ fn bench_stream_1000_empty_lists(b: &mut Bencher) { b.iter(|| { let mut stream = RlpStream::new_list(1000); for _ in 0..1000 { - stream.append_list(0); + stream.begin_list(0); } let _ = stream.out(); }); From 3d6f5a6ca7df79d1bdfdda30cb41c7bd075ca62b Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 02:32:58 +0100 Subject: [PATCH 14/22] fixed typo in travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d64cf4a9e..2663d0d8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && - cargo doc --no-deps --verbose ${KCOV_FEATURES} ${RARGETS} && + cargo doc --no-deps --verbose ${KCOV_FEATURES} ${TARGETS} && echo '' > target/doc/index.html && pip install --user ghp-import && /home/travis/.local/bin/ghp-import -n target/doc From 620146bddac7d1125fd298aa98b45c48cd1b8b54 Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 02:38:15 +0100 Subject: [PATCH 15/22] uncomment rlp benches --- util/benches/rlp.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/benches/rlp.rs b/util/benches/rlp.rs index d2ecb4553..e322143f7 100644 --- a/util/benches/rlp.rs +++ b/util/benches/rlp.rs @@ -3,7 +3,7 @@ //! ```bash //! multirust run nightly cargo bench //! ``` -/* + #![feature(test)] extern crate test; @@ -94,4 +94,3 @@ fn bench_stream_1000_empty_lists(b: &mut Bencher) { let _ = stream.out(); }); } -*/ \ No newline at end of file From 6c10bb32479ebc700b49035222fa3f523a2da84f Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Tue, 2 Feb 2016 03:24:31 -0800 Subject: [PATCH 16/22] local coverage --- cov.sh | 2 +- cov.sh~ | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 cov.sh~ diff --git a/cov.sh b/cov.sh index 371746a39..6936d25be 100755 --- a/cov.sh +++ b/cov.sh @@ -17,5 +17,5 @@ fi cargo test --no-run || exit $? mkdir -p target/coverage -kcov --exclude-pattern ~/.multirust,rocksdb,secp256k1 --include-pattern src --verify target/coverage target/debug/ethcore* +kcov --exclude-pattern ~/.multirust,rocksdb,secp256k1 --include-pattern src --verify target/coverage target/debug/deps/ethcore* xdg-open target/coverage/index.html diff --git a/cov.sh~ b/cov.sh~ new file mode 100755 index 000000000..17466d506 --- /dev/null +++ b/cov.sh~ @@ -0,0 +1,21 @@ +#!/bin/sh +# Installing KCOV under ubuntu +# https://users.rust-lang.org/t/tutorial-how-to-collect-test-coverages-for-rust-project/650# +### Install deps +# $ sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev +# +### Compile kcov +# $ wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xf master.tar.gz +# $ cd kcov-master && mkdir build && cd build +# $ cmake .. && make && sudo make install + +### Running coverage +if ! type kcov > /dev/null; then + echo "Install kcov first (details inside this file). Aborting." + exit 1 +fi + +cargo test --no-run || exit $? +mkdir -p target/coverage +kcov --exclude-pattern ~/.multirust,rocksdb,secp256k1 --include-pattern src --verify target/coverage target/debug/parity* +xdg-open target/coverage/index.html From b119e2cbb1a96b5ab89eca1c55cce68bd98b92c1 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Tue, 2 Feb 2016 03:26:19 -0800 Subject: [PATCH 17/22] removed trash --- cov.sh~ | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100755 cov.sh~ diff --git a/cov.sh~ b/cov.sh~ deleted file mode 100755 index 17466d506..000000000 --- a/cov.sh~ +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Installing KCOV under ubuntu -# https://users.rust-lang.org/t/tutorial-how-to-collect-test-coverages-for-rust-project/650# -### Install deps -# $ sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev -# -### Compile kcov -# $ wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xf master.tar.gz -# $ cd kcov-master && mkdir build && cd build -# $ cmake .. && make && sudo make install - -### Running coverage -if ! type kcov > /dev/null; then - echo "Install kcov first (details inside this file). Aborting." - exit 1 -fi - -cargo test --no-run || exit $? -mkdir -p target/coverage -kcov --exclude-pattern ~/.multirust,rocksdb,secp256k1 --include-pattern src --verify target/coverage target/debug/parity* -xdg-open target/coverage/index.html From 33499fd6984dbcc14e68f19f5b64d7732a3f0a4f Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Tue, 2 Feb 2016 03:32:28 -0800 Subject: [PATCH 18/22] package spec --- cov.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cov.sh b/cov.sh index 6936d25be..a78e36205 100755 --- a/cov.sh +++ b/cov.sh @@ -15,7 +15,7 @@ if ! type kcov > /dev/null; then exit 1 fi -cargo test --no-run || exit $? +cargo test -p ethcore --no-run || exit $? mkdir -p target/coverage kcov --exclude-pattern ~/.multirust,rocksdb,secp256k1 --include-pattern src --verify target/coverage target/debug/deps/ethcore* xdg-open target/coverage/index.html From 3f8fdfaea70e978926e96b02dad7c1f09bbfaefe Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Tue, 2 Feb 2016 14:33:02 +0100 Subject: [PATCH 19/22] Deploying artifacts for releases --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2663d0d8e..7d5ef19eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ script: - cargo build --release --verbose ${FEATURES} - cargo test --release --verbose ${FEATURES} ${TARGETS} - cargo bench --no-run ${FEATURES} ${TARGETS} +- zip -j target/release/parity parity-${TRAVIS_TAG}.zip after_success: | wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && cd ../.. && @@ -53,3 +54,12 @@ env: global: - secure: 3sUjNi9mhdL5h1GTm8LONnDN/SYvUHT+WSkMl93h3nYiLCQXk8eZaPS98AS7oOaTsfW4UvnwckVFCFl49ttInsv4cd/TkAxmrJHe6kPyS9/4NWUdmP8BjicbBvL/ioSdXMECMEYzPDLV+I3KhtC2LcB6ceDEl/XwMOJlzbGf7RbtcXGVQgMLqSYY1YKjQA4vbT5nFgIS/sZu3Z9yFgN0GafnihKcizqoHhdJjs/zxmX+qJepnC6o3V6KcFnS7QHhM1JOr85twE6S422UlvNaEb5ovwLPqmOl5+fA+6shbx4AxFTY6E9Iors+OVY/JliFhrqOdCt0i2P1FUHN4kbGZQkf0rphN/ZOI2uKNFTOyXiPvppfo/ZemKmcqkwkqP9+lf5QqYmtE6hsAYagxn49xJZILl8tAYbdqxF5gxa+TEVrfsBFtz/Sv3q8QhKQNPAmjEcKyMatyEreLUIFEpFTGIco8jN4eXeSoLRdJ+Z75ihttfQWhNfUDgNL30iQLy0AgFSsh/cyb5M8y9lxrGDzDTogvaiKGwr/V45sPkcXWCkmOgMdINqBB6ZtdL3bGHdyjmYj+y3btjf3aP11k++BL0fXIaKn25aS/p/9iyGb1FyGCM03o4ZRQ3YhTOvfMRfRGf6nWbaMx9upv8o5ShSdysewhrnh3082r7u896ny1Ho= - secure: 0/FeVvFl3AhBW0TCPoujY9zOAYoUNMlAz3XjC04vlc4Ksfx0lGU3KFi97LlALxMWV0lfwQc7ixSe2vTgQVQuLVSU9XEW40fQgEjJlmLca2RcRx1kfzJDypuWSiCME7MWmLPH0ac4COdTDS1z5WGggv5YB7GQPCzFvcmOOaPYtF29ngCtkyB2HmNkY/W3omHFEk7Si6bsmOSHZiOAhivPl6ixnGpFyTEKPyraMMqPIj5rbEGkzgeLTiXf2ur143n/tnSr8tmP1MfQi9yS8/ONidMqnxUeuLkeNnb82zj9pVJhVXq0xF44WXJ8Za1jm0ByiTakgqpm8Juk822qjvtNulJ1XZW/fyZQZaN1dy3uq5Ud3W8wS9M7VIVl8CoXozzDpIsdPeUAtkAxeHBsZqL1vAH2yC1YJA7HPySMYzCjYqkJ2r62xYk0gXmNXphfU+F/X/rHzHsTMJPONJ54HQwu12m7zVlKIYBGHgEXg/HAM/g4ljUzl6WWR/nHH/tQM8ND/8FpHluJSZJWacq/1QNhVdTq2x6cqws2fs5A7nVpccR9+6RRgYgv6+YS2LxvFzByuZveGGoKif+uMECXN876j40araUqU528Yz9i8bHJlnM3coRBndaLNWByLcUyXCB9r9IUosUu41rr+L2mVzkSDm0GicuNCzqvzYQ9Q6QY4uQ= + +deploy: + provider: releases + api_key: + secure: ATorsRujvWN9y4bZlUdp2I0hvh3pKkpkrr/oyQyt8ZssE7ORx1+lYgTdYocHyx53uBrGFjRQbSCvdDsrs8c1v2Dh2872TmMQMWgLaeeS6bPiNw7WkJuH1hvvTNAiFCfuT9nnntFvMuKcUpBHQ1eeuEU + skip_cleanup: true + file: parity-${TRAVIS_TAG}.zip + on: + tags: true From 25c87d000441be215911cd00df96b12da937160f Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Tue, 2 Feb 2016 14:43:55 +0100 Subject: [PATCH 20/22] Including OS_NAME in artifact --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d5ef19eb..37d9eafee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: fast_finish: true include: - rust: nightly - env: FEATURES="--features ethcore/json-tests" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" + env: FEATURES="--features ethcore/json-tests" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}" cache: apt: true directories: @@ -30,7 +30,7 @@ script: - cargo build --release --verbose ${FEATURES} - cargo test --release --verbose ${FEATURES} ${TARGETS} - cargo bench --no-run ${FEATURES} ${TARGETS} -- zip -j target/release/parity parity-${TRAVIS_TAG}.zip +- zip -j target/release/parity parity${ARCHIVE_SUFFIX}.zip after_success: | wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && cd ../.. && @@ -60,6 +60,6 @@ deploy: api_key: secure: ATorsRujvWN9y4bZlUdp2I0hvh3pKkpkrr/oyQyt8ZssE7ORx1+lYgTdYocHyx53uBrGFjRQbSCvdDsrs8c1v2Dh2872TmMQMWgLaeeS6bPiNw7WkJuH1hvvTNAiFCfuT9nnntFvMuKcUpBHQ1eeuEU skip_cleanup: true - file: parity-${TRAVIS_TAG}.zip + file: parity${ARCHIVE_SUFFIX}.zip on: tags: true From 8f12989785503d49fa49b053d04d88060f0daba4 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Tue, 2 Feb 2016 15:01:18 +0100 Subject: [PATCH 21/22] Changing packaging to tar.gz --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 37d9eafee..d1cefa6ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ script: - cargo build --release --verbose ${FEATURES} - cargo test --release --verbose ${FEATURES} ${TARGETS} - cargo bench --no-run ${FEATURES} ${TARGETS} -- zip -j target/release/parity parity${ARCHIVE_SUFFIX}.zip +- tar cvzf parity${ARCHIVE_SUFFIX}.tar.gz -C target/release parity after_success: | wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && cd ../.. && @@ -60,6 +60,6 @@ deploy: api_key: secure: ATorsRujvWN9y4bZlUdp2I0hvh3pKkpkrr/oyQyt8ZssE7ORx1+lYgTdYocHyx53uBrGFjRQbSCvdDsrs8c1v2Dh2872TmMQMWgLaeeS6bPiNw7WkJuH1hvvTNAiFCfuT9nnntFvMuKcUpBHQ1eeuEU skip_cleanup: true - file: parity${ARCHIVE_SUFFIX}.zip + file: parity${ARCHIVE_SUFFIX}.tar.gz on: tags: true From 8ea7331d2b667e717ea16f4774e69674111f53af Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Tue, 2 Feb 2016 16:13:42 +0100 Subject: [PATCH 22/22] Building beta-* and stable-* tags --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d1cefa6ba..899174b5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ language: rust branches: only: - master + - /^beta-.*$/ + - /^stable-.*$/ matrix: fast_finish: true include: