From 8802fb2fd83500c6cc373e9b23ebc5ab93772e63 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sat, 13 Feb 2016 02:31:23 +0530 Subject: [PATCH 01/23] Make clippy an optional dependency --- .travis.yml | 2 +- Cargo.lock | 4 ---- Cargo.toml | 3 ++- ethcore/Cargo.toml | 3 ++- ethcore/src/lib.rs | 5 ++--- parity/main.rs | 2 +- rpc/Cargo.toml | 6 +++++- rpc/src/lib.rs | 2 +- sync/Cargo.toml | 6 +++++- sync/src/lib.rs | 4 ++-- util/Cargo.toml | 6 +++++- util/src/lib.rs | 4 ++-- 12 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2859589b..0abda2c30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,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" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}" + env: FEATURES='--features "ethcore/json-tests dev"' 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: diff --git a/Cargo.lock b/Cargo.lock index 1e9f57900..94b9a3b91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -167,7 +167,6 @@ dependencies = [ name = "ethcore" version = "0.9.99" dependencies = [ - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 0.9.99", @@ -186,7 +185,6 @@ dependencies = [ name = "ethcore-rpc" version = "0.9.99" dependencies = [ - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 0.9.99", "ethcore-util 0.9.99", "ethsync 0.9.99", @@ -204,7 +202,6 @@ name = "ethcore-util" version = "0.9.99" dependencies = [ "arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,7 +229,6 @@ dependencies = [ name = "ethsync" version = "0.9.99" dependencies = [ - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 0.9.99", "ethcore-util 0.9.99", diff --git a/Cargo.toml b/Cargo.toml index c58cacf0d..a3fd40e34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rustc-serialize = "0.3" docopt = "0.6" docopt_macros = "0.6" ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" } -clippy = "0.0.41" +clippy = { version = "0.0.41", optional = true } ethcore-util = { path = "util" } ethcore = { path = "ethcore" } ethsync = { path = "sync" } @@ -23,6 +23,7 @@ target_info = "0.1" [features] default = ["rpc"] rpc = ["ethcore-rpc"] +dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev"] [[bin]] path = "parity/main.rs" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 3d4d27520..4aafebba1 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -18,7 +18,7 @@ ethcore-util = { path = "../util" } evmjit = { path = "../evmjit", optional = true } ethash = { path = "../ethash" } num_cpus = "0.2" -clippy = "0.0.41" +clippy = { version = "0.0.41", optional = true } crossbeam = "0.1.5" lazy_static = "0.1" @@ -27,3 +27,4 @@ jit = ["evmjit"] evm-debug = [] json-tests = [] test-heavy = [] +dev = ["clippy"] diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 4cca74319..093906bd0 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -17,9 +17,8 @@ #![warn(missing_docs)] #![feature(cell_extras)] #![feature(augmented_assignments)] -#![feature(plugin)] -// Clippy -#![plugin(clippy)] +#![cfg_attr(feature="dev", feature(plugin))] +#![cfg_attr(feature="dev", plugin(clippy))] // TODO [todr] not really sure #![allow(needless_range_loop)] // Shorter than if-else diff --git a/parity/main.rs b/parity/main.rs index 460922b64..eadaa4968 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -19,7 +19,7 @@ #![warn(missing_docs)] #![feature(plugin)] #![plugin(docopt_macros)] -#![plugin(clippy)] +#![cfg_attr(feature="dev", plugin(clippy))] extern crate docopt; extern crate rustc_serialize; extern crate ethcore_util as util; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index b1af0a2fa..107e22c07 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -16,6 +16,10 @@ jsonrpc-http-server = "1.1.2" ethcore-util = { path = "../util" } ethcore = { path = "../ethcore" } ethsync = { path = "../sync" } -clippy = "0.0.41" +clippy = { version = "0.0.41", optional = true } target_info = "0.1.0" rustc-serialize = "0.3" + +[features] +default = [] +dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev"] diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 0b148c983..cd059e6b1 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -18,7 +18,7 @@ #![warn(missing_docs)] #![feature(custom_derive, custom_attribute, plugin)] #![plugin(serde_macros)] -#![plugin(clippy)] +#![cfg_attr(feature="dev", plugin(clippy))] extern crate rustc_serialize; extern crate target_info; diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 92b46fc57..fc56ba2b9 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -10,8 +10,12 @@ authors = ["Ethcore . #![warn(missing_docs)] -#![feature(plugin)] +#![cfg_attr(feature="dev", feature(plugin))] +#![cfg_attr(feature="dev", plugin(clippy))] #![feature(augmented_assignments)] -#![plugin(clippy)] // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. #![allow(clone_on_copy)] diff --git a/util/Cargo.toml b/util/Cargo.toml index 9ead8ccf6..773e58de3 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -26,7 +26,11 @@ crossbeam = "0.2" slab = { git = "https://github.com/arkpar/slab.git" } sha3 = { path = "sha3" } serde = "0.6.7" -clippy = "0.0.41" +clippy = { version = "0.0.41", optional = true } json-tests = { path = "json-tests" } target_info = "0.1.0" igd = "0.4.2" + +[features] +default = [] +dev = ["clippy"] \ No newline at end of file diff --git a/util/src/lib.rs b/util/src/lib.rs index d4f972800..0a2b0f4b4 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -18,10 +18,10 @@ #![feature(op_assign_traits)] #![feature(augmented_assignments)] #![feature(associated_consts)] -#![feature(plugin)] +#![cfg_attr(feature="dev", feature(plugin))] +#![cfg_attr(feature="dev", plugin(clippy))] #![feature(catch_panic)] // Clippy settings -#![plugin(clippy)] // TODO [todr] not really sure #![allow(needless_range_loop)] // Shorter than if-else From ebe8e19cc0d8152daf13454d0d6231491c3112e3 Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 18 Feb 2016 14:36:59 +0100 Subject: [PATCH 02/23] fixed compiling with rustc 1.8.0-nightly (57c357d89 2016-02-16) --- Cargo.lock | 87 +++++++++++++++++++++++++++++++--------------- Cargo.toml | 2 +- ethcore/Cargo.toml | 2 +- rpc/Cargo.toml | 18 +++++++--- rpc/build.rs | 29 ++++++++++++++++ rpc/src/lib.rs | 44 ++++------------------- rpc/src/lib.rs.in | 30 ++++++++++++++++ sync/Cargo.toml | 2 +- util/Cargo.toml | 2 +- 9 files changed, 142 insertions(+), 74 deletions(-) create mode 100644 rpc/build.rs create mode 100644 rpc/src/lib.rs.in diff --git a/Cargo.lock b/Cargo.lock index 1e9f57900..32a6326f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,7 +2,7 @@ name = "parity" version = "0.9.99" dependencies = [ - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 1.0.1 (git+https://github.com/tomusdrw/rust-ctrlc.git)", "docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)", "docopt_macros 0.6.81 (registry+https://github.com/rust-lang/crates.io-index)", @@ -38,6 +38,9 @@ dependencies = [ name = "aster" version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "bitflags" @@ -61,7 +64,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clippy" -version = "0.0.41" +version = "0.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -167,7 +170,7 @@ dependencies = [ name = "ethcore" version = "0.9.99" dependencies = [ - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 0.9.99", @@ -186,16 +189,17 @@ dependencies = [ name = "ethcore-rpc" version = "0.9.99" dependencies = [ - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 0.9.99", "ethcore-util 0.9.99", "ethsync 0.9.99", - "jsonrpc-core 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -204,7 +208,7 @@ name = "ethcore-util" version = "0.9.99" dependencies = [ "arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,7 +236,7 @@ dependencies = [ name = "ethsync" version = "0.9.99" dependencies = [ - "clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 0.9.99", "ethcore-util 0.9.99", @@ -346,12 +350,13 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -360,7 +365,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hyper 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -529,6 +534,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "quasi" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "quasi_codegen" @@ -536,14 +544,8 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aster 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quasi_macros" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quasi_codegen 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -631,7 +633,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aster 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "quasi 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_macros 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_codegen 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -643,14 +647,6 @@ dependencies = [ "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "serde_macros" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_codegen 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "sha3" version = "0.1.0" @@ -682,11 +678,41 @@ name = "strsim" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "syntex" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_syntax" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "target_info" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "term" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.34" @@ -733,6 +759,11 @@ name = "unicode-normalization" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "url" version = "0.2.38" diff --git a/Cargo.toml b/Cargo.toml index c58cacf0d..0a55038dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rustc-serialize = "0.3" docopt = "0.6" docopt_macros = "0.6" ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" } -clippy = "0.0.41" +clippy = "0.0.42" ethcore-util = { path = "util" } ethcore = { path = "ethcore" } ethsync = { path = "sync" } diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 3d4d27520..5298a253f 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -18,7 +18,7 @@ ethcore-util = { path = "../util" } evmjit = { path = "../evmjit", optional = true } ethash = { path = "../ethash" } num_cpus = "0.2" -clippy = "0.0.41" +clippy = "0.0.42" crossbeam = "0.1.5" lazy_static = "0.1" diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index b1af0a2fa..4e79fa8f5 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -4,18 +4,28 @@ name = "ethcore-rpc" version = "0.9.99" license = "GPL-3.0" authors = ["Ethcore . //! Ethcore rpc. -#![warn(missing_docs)] -#![feature(custom_derive, custom_attribute, plugin)] -#![plugin(serde_macros)] -#![plugin(clippy)] +#![cfg_attr(nightly, feature(custom_derive, custom_attribute, plugin))] +#![cfg_attr(nightly, plugin(serde_macros, clippy))] extern crate rustc_serialize; extern crate target_info; @@ -30,38 +28,8 @@ extern crate ethcore_util as util; extern crate ethcore; extern crate ethsync; -use self::jsonrpc_core::{IoHandler, IoDelegate}; +#[cfg(feature = "serde_macros")] +include!("lib.rs.in"); -pub mod v1; - -/// Http server. -pub struct HttpServer { - handler: IoHandler, - threads: usize -} - -impl HttpServer { - /// Construct new http server object with given number of threads. - pub fn new(threads: usize) -> HttpServer { - HttpServer { - handler: IoHandler::new(), - threads: threads - } - } - - /// Add io delegate. - pub fn add_delegate(&mut self, delegate: IoDelegate) where D: Send + Sync + 'static { - self.handler.add_delegate(delegate); - } - - /// Start server asynchronously in new thread - pub fn start_async(self, addr: &str) { - let server = jsonrpc_http_server::Server::new(self.handler, self.threads); - server.start_async(addr) - } -} - -/// Lib needs at least 1 test to generate coverage reports correctly. -#[test] -fn if_works() { -} +#[cfg(not(feature = "serde_macros"))] +include!(concat!(env!("OUT_DIR"), "/lib.rs")); diff --git a/rpc/src/lib.rs.in b/rpc/src/lib.rs.in new file mode 100644 index 000000000..f09a25be8 --- /dev/null +++ b/rpc/src/lib.rs.in @@ -0,0 +1,30 @@ +use self::jsonrpc_core::{IoHandler, IoDelegate}; + +pub mod v1; + +/// Http server. +pub struct HttpServer { + handler: IoHandler, + threads: usize +} + +impl HttpServer { + /// Construct new http server object with given number of threads. + pub fn new(threads: usize) -> HttpServer { + HttpServer { + handler: IoHandler::new(), + threads: threads + } + } + + /// Add io delegate. + pub fn add_delegate(&mut self, delegate: IoDelegate) where D: Send + Sync + 'static { + self.handler.add_delegate(delegate); + } + + /// Start server asynchronously in new thread + pub fn start_async(self, addr: &str) { + let server = jsonrpc_http_server::Server::new(self.handler, self.threads); + server.start_async(addr) + } +} diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 92b46fc57..db1a7ba82 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Ethcore Date: Thu, 18 Feb 2016 15:17:26 +0100 Subject: [PATCH 03/23] updated heapsizeof --- Cargo.lock | 9 +++------ ethcore/Cargo.toml | 2 +- util/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32a6326f7..f895850a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,7 +175,7 @@ dependencies = [ "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 0.9.99", "ethcore-util 0.9.99", - "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -213,7 +213,7 @@ dependencies = [ "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.4 (git+https://github.com/arkpar/rust-secp256k1.git)", - "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "json-tests 0.1.0", @@ -264,11 +264,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "heapsize" -version = "0.2.5" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "hpack" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 5298a253f..d8df6455a 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -11,7 +11,7 @@ log = "0.3" env_logger = "0.3" rustc-serialize = "0.3" rocksdb = "0.3" -heapsize = "0.2.0" +heapsize = "0.3" rust-crypto = "0.2.34" time = "0.1" ethcore-util = { path = "../util" } diff --git a/util/Cargo.toml b/util/Cargo.toml index 8ca86d26b..a339d10e1 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -20,7 +20,7 @@ lazy_static = "0.1" eth-secp256k1 = { git = "https://github.com/arkpar/rust-secp256k1.git" } rust-crypto = "0.2.34" elastic-array = "0.4" -heapsize = "0.2" +heapsize = "0.3" itertools = "0.4" crossbeam = "0.2" slab = { git = "https://github.com/arkpar/slab.git" } From 198119466b91951145736234cc69483f20885700 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 18 Feb 2016 19:21:24 +0300 Subject: [PATCH 04/23] forking heapsize --- Cargo.lock | 7 ++++++- util/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f895850a7..05f674a69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,7 +213,7 @@ dependencies = [ "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.4 (git+https://github.com/arkpar/rust-secp256k1.git)", - "heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.2 (git+https://github.com/nikvolf/heapsize)", "igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "json-tests 0.1.0", @@ -262,6 +262,11 @@ name = "glob" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "heapsize" +version = "0.3.2" +source = "git+https://github.com/nikvolf/heapsize#7913872a4f928a49659df52e48dea69d8a2376bf" + [[package]] name = "heapsize" version = "0.3.2" diff --git a/util/Cargo.toml b/util/Cargo.toml index a339d10e1..ea618ed45 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -20,7 +20,7 @@ lazy_static = "0.1" eth-secp256k1 = { git = "https://github.com/arkpar/rust-secp256k1.git" } rust-crypto = "0.2.34" elastic-array = "0.4" -heapsize = "0.3" +heapsize = { git = "https://github.com/nikvolf/heapsize" } itertools = "0.4" crossbeam = "0.2" slab = { git = "https://github.com/arkpar/slab.git" } From 8b4278aeaa2bb097c19ba77819cf5abdee72d4dd Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 18 Feb 2016 22:06:59 +0300 Subject: [PATCH 05/23] feature dep for heapsize --- .travis.yml | 1 + Cargo.lock | 7 +------ ethcore/Cargo.toml | 3 ++- util/Cargo.toml | 3 +++ 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2859589b..f7d3b6597 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ cache: - target/debug/build - target/release/deps - target/release/build + - $HOME/.cargo addons: apt: packages: diff --git a/Cargo.lock b/Cargo.lock index 05f674a69..ad2a13c92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,7 +175,7 @@ dependencies = [ "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 0.9.99", "ethcore-util 0.9.99", - "heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.2 (git+https://github.com/nikvolf/heapsize)", "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -267,11 +267,6 @@ name = "heapsize" version = "0.3.2" source = "git+https://github.com/nikvolf/heapsize#7913872a4f928a49659df52e48dea69d8a2376bf" -[[package]] -name = "heapsize" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "hpack" version = "0.2.0" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index d8df6455a..6eb9dec22 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -11,7 +11,7 @@ log = "0.3" env_logger = "0.3" rustc-serialize = "0.3" rocksdb = "0.3" -heapsize = "0.3" +heapsize = { git = "https://github.com/nikvolf/heapsize" } rust-crypto = "0.2.34" time = "0.1" ethcore-util = { path = "../util" } @@ -27,3 +27,4 @@ jit = ["evmjit"] evm-debug = [] json-tests = [] test-heavy = [] +default = [ "heapsize/nightly" ] diff --git a/util/Cargo.toml b/util/Cargo.toml index ea618ed45..9e32aea06 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -6,6 +6,9 @@ name = "ethcore-util" version = "0.9.99" authors = ["Ethcore "] +[features] +default = [ "heapsize/nightly" ] + [dependencies] log = "0.3" env_logger = "0.3" From 031b15daabb9d671e72822c0df541236d32b2f20 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 18 Feb 2016 22:12:25 +0300 Subject: [PATCH 06/23] update cargo.lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index ad2a13c92..08e1e8775 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -265,7 +265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "heapsize" version = "0.3.2" -source = "git+https://github.com/nikvolf/heapsize#7913872a4f928a49659df52e48dea69d8a2376bf" +source = "git+https://github.com/nikvolf/heapsize#a2d682fd4dcf11e2deeeb229ef2375354c15668b" [[package]] name = "hpack" From beb0da4ff4e064d592806722c839ec8784e8b5f7 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 18 Feb 2016 22:56:21 +0300 Subject: [PATCH 07/23] and adding actual dependency --- ethcore/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 6eb9dec22..207db69fc 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -25,6 +25,6 @@ lazy_static = "0.1" [features] jit = ["evmjit"] evm-debug = [] -json-tests = [] +json-tests = [ "heapsize/nightly" ] test-heavy = [] default = [ "heapsize/nightly" ] From cc5384fff51c052d3985976c8901dffef7cee874 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 18 Feb 2016 22:35:14 +0100 Subject: [PATCH 08/23] Get rid of lru_cache dependency --- ethash/Cargo.toml | 1 - ethash/src/lib.rs | 58 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/ethash/Cargo.toml b/ethash/Cargo.toml index 4bba71a14..da08b9f92 100644 --- a/ethash/Cargo.toml +++ b/ethash/Cargo.toml @@ -7,5 +7,4 @@ authors = ["arkpar , + recent: Option>, + prev_epoch: Option, + prev: Option>, +} + /// Lighy/Full cache manager pub struct EthashManager { - lights: Mutex>> + cache: Mutex, } impl EthashManager { /// Create a new new instance of ethash manager pub fn new() -> EthashManager { EthashManager { - lights: Mutex::new(LruCache::new(2)) + cache: Mutex::new(LightCache { + recent_epoch: None, + recent: None, + prev_epoch: None, + prev: None, + }), } } @@ -50,8 +61,24 @@ impl EthashManager { pub fn compute_light(&self, block_number: u64, header_hash: &H256, nonce: u64) -> ProofOfWork { let epoch = block_number / ETHASH_EPOCH_LENGTH; let light = { - let mut lights = self.lights.lock().unwrap(); - match lights.get_mut(&epoch).map(|l| l.clone()) { + let mut lights = self.cache.lock().unwrap(); + let light = match lights.recent_epoch.clone() { + Some(ref e) if *e == epoch => lights.recent.clone(), + _ => match lights.prev_epoch.clone() { + Some(e) if e == epoch => { + // swap + let t = lights.prev_epoch; + lights.prev_epoch = lights.recent_epoch; + lights.recent_epoch = t; + let t = lights.prev.clone(); + lights.prev = lights.recent.clone(); + lights.recent = t; + lights.recent.clone() + } + _ => None, + } + }; + match light { None => { let light = match Light::from_file(block_number) { Ok(light) => Arc::new(light), @@ -64,7 +91,8 @@ impl EthashManager { Arc::new(light) } }; - lights.insert(epoch, light.clone()); + lights.prev_epoch = mem::replace(&mut lights.recent_epoch, Some(epoch)); + lights.prev = mem::replace(&mut lights.recent, Some(light.clone())); light } Some(light) => light @@ -73,3 +101,19 @@ impl EthashManager { light.compute(header_hash, nonce) } } + +#[test] +fn test_lru() { + let ethash = EthashManager::new(); + let hash = [0u8; 32]; + ethash.compute_light(1, &hash, 1); + ethash.compute_light(50000, &hash, 1); + assert_eq!(ethash.cache.lock().unwrap().recent_epoch.unwrap(), 1); + assert_eq!(ethash.cache.lock().unwrap().prev_epoch.unwrap(), 0); + ethash.compute_light(1, &hash, 1); + assert_eq!(ethash.cache.lock().unwrap().recent_epoch.unwrap(), 0); + assert_eq!(ethash.cache.lock().unwrap().prev_epoch.unwrap(), 1); + ethash.compute_light(70000, &hash, 1); + assert_eq!(ethash.cache.lock().unwrap().recent_epoch.unwrap(), 2); + assert_eq!(ethash.cache.lock().unwrap().prev_epoch.unwrap(), 0); +} From af8ba067951dd1ed4bc3b36803015012f1b2736f Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 18 Feb 2016 23:29:41 +0100 Subject: [PATCH 09/23] utils compilable in beta --- Cargo.lock | 120 ++++++++++++++++------------------ Cargo.toml | 1 - ethcore/src/lib.rs | 2 - util/Cargo.toml | 5 +- util/src/hash.rs | 9 --- util/src/lib.rs | 4 -- util/src/panics.rs | 25 ++++--- util/src/rlp/bytes.rs | 8 +-- util/src/rlp/untrusted_rlp.rs | 1 - util/src/uint.rs | 96 --------------------------- 10 files changed, 75 insertions(+), 196 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6cdb6f53f..236969732 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,6 @@ dependencies = [ "ctrlc 1.0.1 (git+https://github.com/tomusdrw/rust-ctrlc.git)", "daemonize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)", - "docopt_macros 0.6.81 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 0.9.99", "ethcore-rpc 0.9.99", @@ -20,7 +19,7 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -37,10 +36,10 @@ dependencies = [ [[package]] name = "aster" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -69,7 +68,7 @@ version = "0.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -130,14 +129,6 @@ dependencies = [ "strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "docopt_macros" -version = "0.6.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "elastic-array" version = "0.4.0" @@ -155,14 +146,14 @@ dependencies = [ [[package]] name = "eth-secp256k1" version = "0.5.4" -source = "git+https://github.com/arkpar/rust-secp256k1.git#321e6c22a83606d1875f89cb61c9cb37c7d249ae" +source = "git+https://github.com/arkpar/rust-secp256k1.git#45503e1de68d909b1862e3f2bdb9e1cdfdff3f1e" dependencies = [ "arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -171,7 +162,6 @@ name = "ethash" version = "0.9.99" dependencies = [ "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lru-cache 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.1.0", ] @@ -179,6 +169,7 @@ dependencies = [ name = "ethcore" version = "0.9.99" dependencies = [ + "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 0.9.99", @@ -197,18 +188,15 @@ dependencies = [ name = "ethcore-rpc" version = "0.9.99" dependencies = [ -<<<<<<< HEAD -======= "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> rustup "ethcore 0.9.99", "ethcore-util 0.9.99", "ethsync 0.9.99", "jsonrpc-core 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -219,10 +207,7 @@ name = "ethcore-util" version = "0.9.99" dependencies = [ "arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD -======= "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> rustup "crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -238,7 +223,7 @@ dependencies = [ "rocksdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.1.0", "slab 0.1.4 (git+https://github.com/arkpar/slab.git)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -250,10 +235,7 @@ dependencies = [ name = "ethsync" version = "0.9.99" dependencies = [ -<<<<<<< HEAD -======= "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> rustup "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 0.9.99", "ethcore-util 0.9.99", @@ -367,8 +349,8 @@ name = "jsonrpc-core" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -416,11 +398,6 @@ name = "libc" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "linked-hash-map" -version = "0.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "log" version = "0.3.5" @@ -429,14 +406,6 @@ dependencies = [ "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "lru-cache" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "linked-hash-map 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "matches" version = "0.1.2" @@ -456,7 +425,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -522,7 +491,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -546,20 +515,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quasi" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quasi_codegen" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aster 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -575,7 +544,7 @@ name = "regex" version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -613,7 +582,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc_version" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -626,7 +595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "semver" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nom 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -634,22 +603,22 @@ dependencies = [ [[package]] name = "serde" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_codegen" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aster 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_codegen 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -657,8 +626,8 @@ name = "serde_json" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -700,6 +669,14 @@ dependencies = [ "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syntex_syntax" version = "0.28.0" @@ -713,6 +690,19 @@ dependencies = [ "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex_syntax" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "target_info" version = "0.1.0" @@ -757,7 +747,7 @@ name = "unicase" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc_version 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8b9924a54..6ffc3d2b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ log = "0.3" env_logger = "0.3" rustc-serialize = "0.3" docopt = "0.6" -docopt_macros = "0.6" ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" } clippy = { version = "0.0.42", optional = true } ethcore-util = { path = "util" } diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 093906bd0..8c9fcaff1 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -15,8 +15,6 @@ // along with Parity. If not, see . #![warn(missing_docs)] -#![feature(cell_extras)] -#![feature(augmented_assignments)] #![cfg_attr(feature="dev", feature(plugin))] #![cfg_attr(feature="dev", plugin(clippy))] // TODO [todr] not really sure diff --git a/util/Cargo.toml b/util/Cargo.toml index 25626780f..ff3fbc5dc 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -6,9 +6,6 @@ name = "ethcore-util" version = "0.9.99" authors = ["Ethcore "] -[features] -default = [ "heapsize/nightly" ] - [dependencies] log = "0.3" env_logger = "0.3" @@ -36,4 +33,4 @@ igd = "0.4.2" [features] default = [] -dev = ["clippy"] \ No newline at end of file +dev = ["clippy"] diff --git a/util/src/hash.rs b/util/src/hash.rs index 2e6c565b4..924465e70 100644 --- a/util/src/hash.rs +++ b/util/src/hash.rs @@ -413,15 +413,6 @@ macro_rules! impl_hash { } } - /// Moving BitOrAssign - impl<'a> BitOrAssign<&'a $from> for $from { - fn bitor_assign(&mut self, rhs: &'a Self) { - for i in 0..$size { - self.0[i] = self.0[i] | rhs.0[i]; - } - } - } - /// BitAnd on references impl <'a> BitAnd for &'a $from { type Output = $from; diff --git a/util/src/lib.rs b/util/src/lib.rs index 0a2b0f4b4..ef76bb885 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -15,12 +15,8 @@ // along with Parity. If not, see . #![warn(missing_docs)] -#![feature(op_assign_traits)] -#![feature(augmented_assignments)] -#![feature(associated_consts)] #![cfg_attr(feature="dev", feature(plugin))] #![cfg_attr(feature="dev", plugin(clippy))] -#![feature(catch_panic)] // Clippy settings // TODO [todr] not really sure #![allow(needless_range_loop)] diff --git a/util/src/panics.rs b/util/src/panics.rs index 27dd605f0..bc22282d2 100644 --- a/util/src/panics.rs +++ b/util/src/panics.rs @@ -40,6 +40,18 @@ pub trait MayPanic { fn on_panic(&self, closure: F) where F: OnPanicListener; } +struct PanicGuard<'a> { + handler: &'a PanicHandler, +} + +impl<'a> Drop for PanicGuard<'a> { + fn drop(&mut self) { + if thread::panicking() { + self.handler.notify_all("Panic!".to_owned()); + } + } +} + /// Structure that allows to catch panics and notify listeners pub struct PanicHandler { listeners: Mutex>> @@ -63,16 +75,9 @@ impl PanicHandler { #[allow(deprecated)] // TODO [todr] catch_panic is deprecated but panic::recover has different bounds (not allowing mutex) pub fn catch_panic(&self, g: G) -> thread::Result where G: FnOnce() -> R + Send + 'static { - let result = thread::catch_panic(g); - - if let Err(ref e) = result { - let res = convert_to_string(e); - if let Some(r) = res { - self.notify_all(r); - } - } - - result + let guard = PanicGuard { handler: self }; + let result = g(); + Ok(result) } fn notify_all(&self, r: String) { diff --git a/util/src/rlp/bytes.rs b/util/src/rlp/bytes.rs index 3b25c09ae..305ec9088 100644 --- a/util/src/rlp/bytes.rs +++ b/util/src/rlp/bytes.rs @@ -232,12 +232,12 @@ impl_uint_from_bytes!(u64); impl_uint_from_bytes!(usize); macro_rules! impl_uint_from_bytes { - ($name: ident) => { + ($name: ident, $size: expr) => { impl FromBytes for $name { fn from_bytes(bytes: &[u8]) -> FromBytesResult<$name> { if !bytes.is_empty() && bytes[0] == 0 { Err(FromBytesError::ZeroPrefixedInt) - } else if bytes.len() <= $name::SIZE { + } else if bytes.len() <= $size { Ok($name::from(bytes)) } else { Err(FromBytesError::DataIsTooLong) @@ -247,8 +247,8 @@ macro_rules! impl_uint_from_bytes { } } -impl_uint_from_bytes!(U256); -impl_uint_from_bytes!(U128); +impl_uint_from_bytes!(U256, 256); +impl_uint_from_bytes!(U128, 128); impl FromBytes for T where T: FixedHash { fn from_bytes(bytes: &[u8]) -> FromBytesResult { diff --git a/util/src/rlp/untrusted_rlp.rs b/util/src/rlp/untrusted_rlp.rs index 463d5cb2f..957a09b61 100644 --- a/util/src/rlp/untrusted_rlp.rs +++ b/util/src/rlp/untrusted_rlp.rs @@ -429,7 +429,6 @@ impl Decodable for Option where T: Decodable { macro_rules! impl_array_decodable { ($index_type:ty, $len:expr ) => ( impl Decodable for [T; $len] where T: Decodable { - #[allow(len_zero)] fn decode(decoder: &D) -> Result where D: Decoder { let decoders = decoder.as_rlp(); diff --git a/util/src/uint.rs b/util/src/uint.rs index b3427f6bc..912088fb9 100644 --- a/util/src/uint.rs +++ b/util/src/uint.rs @@ -78,9 +78,6 @@ macro_rules! panic_on_overflow { /// Large, fixed-length unsigned integer type. pub trait Uint: Sized + Default + FromStr + From + FromJson + fmt::Debug + fmt::Display + PartialOrd + Ord + PartialEq + Eq + Hash { - /// Size of this type. - const SIZE: usize; - /// Returns new instance equalling zero. fn zero() -> Self; /// Returns new instance equalling one. @@ -148,8 +145,6 @@ macro_rules! construct_uint { pub struct $name(pub [u64; $n_words]); impl Uint for $name { - const SIZE: usize = $n_words * 8; - type FromDecStrErr = FromHexError; /// TODO: optimize, throw appropriate err @@ -634,66 +629,6 @@ macro_rules! construct_uint { // TODO: optimise and traitify. - impl<'a> AddAssign<&'a $name> for $name { - fn add_assign(&mut self, other: &'a Self) { - *self = self.add(*other); - } - } - - impl<'a> SubAssign<&'a $name> for $name { - fn sub_assign(&mut self, other: &'a Self) { - *self = self.sub(*other); - } - } - - impl<'a> MulAssign<&'a $name> for $name { - fn mul_assign(&mut self, other: &'a Self) { - *self = self.mul(*other); - } - } - - impl<'a> DivAssign<&'a $name> for $name { - fn div_assign(&mut self, other: &'a Self) { - *self = self.div(*other); - } - } - - impl<'a> RemAssign<&'a $name> for $name { - fn rem_assign(&mut self, other: &'a Self) { - *self = self.rem(*other); - } - } - - impl AddAssign<$name> for $name { - fn add_assign(&mut self, other: Self) { - *self = self.add(other); - } - } - - impl SubAssign<$name> for $name { - fn sub_assign(&mut self, other: Self) { - *self = self.sub(other); - } - } - - impl MulAssign<$name> for $name { - fn mul_assign(&mut self, other: Self) { - *self = self.mul(other); - } - } - - impl DivAssign<$name> for $name { - fn div_assign(&mut self, other: Self) { - *self = self.div(other); - } - } - - impl RemAssign<$name> for $name { - fn rem_assign(&mut self, other: Self) { - *self = self.rem(other); - } - } - impl BitAnd<$name> for $name { type Output = $name; @@ -964,37 +899,6 @@ mod tests { use uint::{Uint, U128, U256, U512}; use std::str::FromStr; - #[test] - pub fn assign_ops() { - let x: U256 = x!(69); - let y: U256 = x!(42); - { - let mut z = x; - z += y; - assert_eq!(z, x + y); - } - { - let mut z = x; - z -= y; - assert_eq!(z, x - y); - } - { - let mut z = x; - z *= y; - assert_eq!(z, x * y); - } - { - let mut z = x; - z /= y; - assert_eq!(z, x / y); - } - { - let mut z = x; - z %= y; - assert_eq!(z, x % y); - } - } - #[test] pub fn uint256_from() { let e = U256([10, 0, 0, 0]); From df3d17789a0c835e994ea69b53cb04eba979637e Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 00:06:06 +0100 Subject: [PATCH 10/23] compiling ethcore on beta --- Cargo.lock | 6 +++--- ethcore/Cargo.toml | 6 +++--- ethcore/src/block.rs | 2 +- ethcore/src/client.rs | 2 +- ethcore/src/evm/interpreter.rs | 4 ++-- ethcore/src/lib.rs | 1 - ethcore/src/receipt.rs | 2 +- ethcore/src/state.rs | 13 ++++++------- util/Cargo.toml | 2 +- 9 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 236969732..b21fb1d63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,7 +174,7 @@ dependencies = [ "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 0.9.99", "ethcore-util 0.9.99", - "heapsize 0.3.2 (git+https://github.com/nikvolf/heapsize)", + "heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -212,7 +212,7 @@ dependencies = [ "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.4 (git+https://github.com/arkpar/rust-secp256k1.git)", - "heapsize 0.3.2 (git+https://github.com/nikvolf/heapsize)", + "heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "json-tests 0.1.0", @@ -264,7 +264,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "heapsize" version = "0.3.2" -source = "git+https://github.com/nikvolf/heapsize#a2d682fd4dcf11e2deeeb229ef2375354c15668b" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hpack" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index dee169c7e..090280cae 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -11,7 +11,7 @@ log = "0.3" env_logger = "0.3" rustc-serialize = "0.3" rocksdb = "0.3" -heapsize = { git = "https://github.com/nikvolf/heapsize" } +heapsize = "0.3" rust-crypto = "0.2.34" time = "0.1" ethcore-util = { path = "../util" } @@ -25,7 +25,7 @@ lazy_static = "0.1" [features] jit = ["evmjit"] evm-debug = [] -json-tests = [ "heapsize/nightly" ] +json-tests = [] test-heavy = [] dev = ["clippy"] -default = [ "heapsize/nightly" ] +default = [] diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index c03417dc1..b646c4cde 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -267,7 +267,7 @@ impl<'x, 'y> OpenBlock<'x, 'y> { s.block.base.header.uncles_hash = uncle_bytes.sha3(); s.block.base.header.state_root = s.block.state.root().clone(); s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|ref r| r.rlp_bytes().to_vec()).collect()); - s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b |= &r.log_bloom; b}); + s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b}); s.block.base.header.gas_used = s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used); s.block.base.header.note_dirty(); diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 09f7417e8..72e520ad7 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -162,7 +162,7 @@ impl ClientReport { pub fn accrue_block(&mut self, block: &PreVerifiedBlock) { self.blocks_imported += 1; self.transactions_applied += block.transactions.len(); - self.gas_processed += block.header.gas_used; + self.gas_processed = self.gas_processed + block.header.gas_used; } } diff --git a/ethcore/src/evm/interpreter.rs b/ethcore/src/evm/interpreter.rs index 50c0377ac..c04b7e1a9 100644 --- a/ethcore/src/evm/interpreter.rs +++ b/ethcore/src/evm/interpreter.rs @@ -299,7 +299,7 @@ impl evm::Evm for Interpreter { let (gas_cost, mem_size) = try!(self.get_gas_cost_mem(ext, instruction, &mut mem, &stack)); try!(self.verify_gas(¤t_gas, &gas_cost)); mem.expand(mem_size); - current_gas -= gas_cost; + current_gas = current_gas - gas_cost; evm_debug!({ println!("[0x{:x}][{}(0x{:x}) Gas: {:x}\n Gas Before: {:x}", @@ -320,7 +320,7 @@ impl evm::Evm for Interpreter { match result { InstructionResult::Ok => {}, InstructionResult::UnusedGas(gas) => { - current_gas += gas; + current_gas = current_gas + gas; }, InstructionResult::UseAllGas => { current_gas = U256::zero(); diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 8c9fcaff1..11d129f61 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -24,7 +24,6 @@ // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. #![allow(clone_on_copy)] - //! Ethcore library //! //! ### Rust version: diff --git a/ethcore/src/receipt.rs b/ethcore/src/receipt.rs index 5fc1a318b..cd1897535 100644 --- a/ethcore/src/receipt.rs +++ b/ethcore/src/receipt.rs @@ -39,7 +39,7 @@ impl Receipt { Receipt { state_root: state_root, gas_used: gas_used, - log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b |= &l.bloom(); b }), + log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b = b | l.bloom(); b }), logs: logs, } } diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index 00886b89c..3eaedb9bf 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -282,7 +282,7 @@ impl State { /// Pull account `a` in our cache from the trie DB and return it. /// `require_code` requires that the code be cached, too. - fn get(&self, a: &Address, require_code: bool) -> Ref> { + fn get<'a>(&'a self, a: &Address, require_code: bool) -> &'a Option { let have_key = self.cache.borrow().contains_key(a); if !have_key { self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp)) @@ -292,17 +292,17 @@ impl State { account.cache_code(&AccountDB::new(&self.db, a)); } } - Ref::map(self.cache.borrow(), |m| m.get(a).unwrap()) + unsafe { ::std::mem::transmute(self.cache.borrow().get(a).unwrap()) } } /// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too. - fn require(&self, a: &Address, require_code: bool) -> RefMut { + fn require<'a>(&'a self, a: &Address, require_code: bool) -> &'a mut Account { self.require_or_from(a, require_code, || Account::new_basic(U256::from(0u8), self.account_start_nonce), |_|{}) } /// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too. /// If it doesn't exist, make account equal the evaluation of `default`. - fn require_or_from Account, G: FnOnce(&mut Account)>(&self, a: &Address, require_code: bool, default: F, not_default: G) -> RefMut { + fn require_or_from<'a, F: FnOnce() -> Account, G: FnOnce(&mut Account)>(&self, a: &Address, require_code: bool, default: F, not_default: G) -> &'a mut Account { let have_key = self.cache.borrow().contains_key(a); if !have_key { self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp)) @@ -316,13 +316,12 @@ impl State { not_default(self.cache.borrow_mut().get_mut(a).unwrap().as_mut().unwrap()); } - let b = self.cache.borrow_mut(); - RefMut::map(b, |m| m.get_mut(a).unwrap().as_mut().map(|account| { + unsafe { ::std::mem::transmute(self.cache.borrow_mut().get_mut(a).unwrap().as_mut().map(|account| { if require_code { account.cache_code(&AccountDB::new(&self.db, a)); } account - }).unwrap()) + }).unwrap()) } } } diff --git a/util/Cargo.toml b/util/Cargo.toml index ff3fbc5dc..18e9a0a75 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -20,7 +20,7 @@ lazy_static = "0.1" eth-secp256k1 = { git = "https://github.com/arkpar/rust-secp256k1.git" } rust-crypto = "0.2.34" elastic-array = "0.4" -heapsize = { git = "https://github.com/nikvolf/heapsize" } +heapsize = "0.3" itertools = "0.4" crossbeam = "0.2" slab = { git = "https://github.com/arkpar/slab.git" } From 8fa62130e3548614452d22f22f6fb45409ab1815 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 19 Feb 2016 00:23:05 +0100 Subject: [PATCH 11/23] Added TODOs --- ethcore/src/block.rs | 2 +- ethcore/src/evm/interpreter.rs | 4 ++-- ethcore/src/receipt.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index b646c4cde..d72fbd1ae 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -267,7 +267,7 @@ impl<'x, 'y> OpenBlock<'x, 'y> { s.block.base.header.uncles_hash = uncle_bytes.sha3(); s.block.base.header.state_root = s.block.state.root().clone(); s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|ref r| r.rlp_bytes().to_vec()).collect()); - s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b}); + s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b}); //TODO: use |= operator s.block.base.header.gas_used = s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used); s.block.base.header.note_dirty(); diff --git a/ethcore/src/evm/interpreter.rs b/ethcore/src/evm/interpreter.rs index c04b7e1a9..7efd79d00 100644 --- a/ethcore/src/evm/interpreter.rs +++ b/ethcore/src/evm/interpreter.rs @@ -299,7 +299,7 @@ impl evm::Evm for Interpreter { let (gas_cost, mem_size) = try!(self.get_gas_cost_mem(ext, instruction, &mut mem, &stack)); try!(self.verify_gas(¤t_gas, &gas_cost)); mem.expand(mem_size); - current_gas = current_gas - gas_cost; + current_gas = current_gas - gas_cost; //TODO: use operator -= evm_debug!({ println!("[0x{:x}][{}(0x{:x}) Gas: {:x}\n Gas Before: {:x}", @@ -320,7 +320,7 @@ impl evm::Evm for Interpreter { match result { InstructionResult::Ok => {}, InstructionResult::UnusedGas(gas) => { - current_gas = current_gas + gas; + current_gas = current_gas + gas; //TODO: use operator += }, InstructionResult::UseAllGas => { current_gas = U256::zero(); diff --git a/ethcore/src/receipt.rs b/ethcore/src/receipt.rs index cd1897535..59c842cd4 100644 --- a/ethcore/src/receipt.rs +++ b/ethcore/src/receipt.rs @@ -39,7 +39,7 @@ impl Receipt { Receipt { state_root: state_root, gas_used: gas_used, - log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b = b | l.bloom(); b }), + log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b = &b | &l.bloom(); b }), //TODO: use |= operator logs: logs, } } From 19a3daf533ebf223951dbbe41cc51e8ff70a6715 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 00:50:23 +0100 Subject: [PATCH 12/23] parity compiling fine --- Cargo.lock | 31 +++++-------------------------- parity/main.rs | 2 +- rpc/Cargo.toml | 2 +- sync/src/lib.rs | 4 ++-- sync/src/tests/helpers.rs | 5 ++++- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b21fb1d63..b69736c2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -192,13 +192,13 @@ dependencies = [ "ethcore 0.9.99", "ethcore-util 0.9.99", "ethsync 0.9.99", - "jsonrpc-core 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -346,13 +346,13 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -361,7 +361,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hyper 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -661,14 +661,6 @@ name = "strsim" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "syntex" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "syntex_syntax 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syntex" version = "0.29.0" @@ -677,19 +669,6 @@ dependencies = [ "syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "syntex_syntax" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syntex_syntax" version = "0.29.0" diff --git a/parity/main.rs b/parity/main.rs index 4238a9333..3279e1fed 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -17,7 +17,7 @@ //! Ethcore client application. #![warn(missing_docs)] -#![feature(plugin)] +#![cfg_attr(feature="dev", feature(plugin))] #![cfg_attr(feature="dev", plugin(clippy))] extern crate docopt; extern crate rustc_serialize; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index f179b0c66..5e25b7901 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -23,7 +23,7 @@ serde_macros = { version = "0.6.13", optional = true } [build-dependencies] serde_codegen = { "version" = "0.6.13", "optional" = true } -syntex = "0.28.0" +syntex = "0.29.0" [features] default = ["serde_codegen"] diff --git a/sync/src/lib.rs b/sync/src/lib.rs index e80a89e50..2be662b65 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -17,7 +17,7 @@ #![warn(missing_docs)] #![cfg_attr(feature="dev", feature(plugin))] #![cfg_attr(feature="dev", plugin(clippy))] -#![feature(augmented_assignments)] +//#![feature(augmented_assignments)] // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. #![allow(clone_on_copy)] @@ -59,7 +59,7 @@ use std::ops::*; use std::sync::*; use ethcore::client::Client; use util::network::{NetworkProtocolHandler, NetworkService, NetworkContext, PeerId}; -use util::io::TimerToken; +use util::TimerToken; use chain::ChainSync; use ethcore::service::SyncMessage; use io::NetSyncIo; diff --git a/sync/src/tests/helpers.rs b/sync/src/tests/helpers.rs index c561b65a3..8c8b3b10a 100644 --- a/sync/src/tests/helpers.rs +++ b/sync/src/tests/helpers.rs @@ -213,7 +213,10 @@ impl BlockChainClient for TestBlockChainClient { } let len = self.numbers.read().unwrap().len(); if number == len { - *self.difficulty.write().unwrap().deref_mut() += header.difficulty; + { + let mut difficulty = self.difficulty.write().unwrap(); + *difficulty.deref_mut() = *difficulty.deref() + header.difficulty; + } mem::replace(self.last_hash.write().unwrap().deref_mut(), h.clone()); self.blocks.write().unwrap().insert(h.clone(), b); self.numbers.write().unwrap().insert(number, h.clone()); From c0aca706d25e9769fdafff8241e7c00a1365fe24 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 00:51:17 +0100 Subject: [PATCH 13/23] removed commented out line --- sync/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 2be662b65..d6bce2447 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -17,7 +17,6 @@ #![warn(missing_docs)] #![cfg_attr(feature="dev", feature(plugin))] #![cfg_attr(feature="dev", plugin(clippy))] -//#![feature(augmented_assignments)] // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. #![allow(clone_on_copy)] From 1486b7e6a090c76c0858df49c5dad2072df5dfbf Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 00:55:57 +0100 Subject: [PATCH 14/23] add beta to build matrix --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0d27ff239..b08e65cf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,8 @@ branches: matrix: fast_finish: true include: + - rust: beta + env: FEATURES='--features "ethcore/json-tests dev"' KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}" - rust: nightly env: FEATURES='--features "ethcore/json-tests dev"' 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: From f45b2f9a243861f175b9d5e1ea090ae5cfe551aa Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 01:13:00 +0100 Subject: [PATCH 15/23] .travis matrix fixes for rust beta --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b08e65cf3..5c8cbe1d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,14 @@ branches: - /^beta$/ - /^stable$/ matrix: - fast_finish: true + fast_finish: false + allow_failures: + - rust: nightly include: - rust: beta - env: FEATURES='--features "ethcore/json-tests dev"' KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}" + 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}" - rust: nightly - env: FEATURES='--features "ethcore/json-tests dev"' KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}" + env: FEATURES="--features 'ethcore/json-tests dev'" 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: @@ -50,7 +52,7 @@ after_success: | ./kcov-master/tmp/usr/local/bin/kcov --coveralls-id=${TRAVIS_JOB_ID} --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/parity-* && [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && - [ $TRAVIS_RUST_VERSION = nightly ] && + [ $TRAVIS_RUST_VERSION = beta ] && cargo doc --no-deps --verbose ${KCOV_FEATURES} ${TARGETS} && echo '' > target/doc/index.html && pip install --user ghp-import && From e3e84020f477d2668e5468d45c02e9779593ce23 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 01:25:06 +0100 Subject: [PATCH 16/23] travis-beta and travis-nightly feaetures --- .travis.yml | 4 ++-- Cargo.toml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5c8cbe1d1..60435a1c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,9 @@ matrix: - rust: nightly include: - rust: beta - 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}" + env: FEATURES="--features travis-beta" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}" - rust: nightly - env: FEATURES="--features 'ethcore/json-tests dev'" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}" + env: FEATURES="--features travis-nightly" 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: diff --git a/Cargo.toml b/Cargo.toml index 6ffc3d2b2..5b59b26f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,8 @@ daemonize = "0.2" default = ["rpc"] rpc = ["ethcore-rpc"] dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev"] +travis-beta = ["ethcore/json-tests"] +travis-nightly = ["ethcore/json-tests", "dev"] [[bin]] path = "parity/main.rs" From bef6d5f2a1f3c267ffc5f25f4f3d28f117ca9d49 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 10:51:17 +0100 Subject: [PATCH 17/23] fixed insecure rlp uint conversion, and failing json tests --- util/src/rlp/bytes.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/src/rlp/bytes.rs b/util/src/rlp/bytes.rs index 305ec9088..2ff6281cc 100644 --- a/util/src/rlp/bytes.rs +++ b/util/src/rlp/bytes.rs @@ -247,8 +247,8 @@ macro_rules! impl_uint_from_bytes { } } -impl_uint_from_bytes!(U256, 256); -impl_uint_from_bytes!(U128, 128); +impl_uint_from_bytes!(U256, 32); +impl_uint_from_bytes!(U128, 16); impl FromBytes for T where T: FixedHash { fn from_bytes(bytes: &[u8]) -> FromBytesResult { From 2ad8f6bd747e2011c8d43b610fcf76c7d9be143a Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 11:03:02 +0100 Subject: [PATCH 18/23] do not run benches on travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 60435a1c6..6ab9a08b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ before_script: | script: - cargo build --release --verbose ${FEATURES} - cargo test --release --verbose ${FEATURES} ${TARGETS} -- cargo bench --no-run ${FEATURES} ${TARGETS} +#- cargo bench --no-run ${FEATURES} ${TARGETS} - tar cvzf parity${ARCHIVE_SUFFIX}.tar.gz -C target/release parity after_success: | wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && From 8831e73d9842100071cb4fd0014a904ef0ed4fc3 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 19 Feb 2016 11:05:39 +0100 Subject: [PATCH 19/23] ignore panic forwarding tests --- util/src/panics.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/src/panics.rs b/util/src/panics.rs index bc22282d2..6bd8fc1d6 100644 --- a/util/src/panics.rs +++ b/util/src/panics.rs @@ -116,6 +116,7 @@ fn convert_to_string(t: &Box) -> Option { } #[test] +#[ignore] // panic forwarding doesnt work on the same thread in beta fn should_notify_listeners_about_panic () { use std::sync::RwLock; // given @@ -132,6 +133,7 @@ fn should_notify_listeners_about_panic () { } #[test] +#[ignore] // panic forwarding doesnt work on the same thread in beta fn should_notify_listeners_about_panic_when_string_is_dynamic () { use std::sync::RwLock; // given @@ -169,6 +171,7 @@ fn should_notify_listeners_about_panic_in_other_thread () { } #[test] +#[ignore] // panic forwarding doesnt work on the same thread in beta fn should_forward_panics () { use std::sync::RwLock; // given From ba4c2c94ec96d433e1c62edff40f927cf08ed503 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 19 Feb 2016 11:26:24 +0100 Subject: [PATCH 20/23] Update Cargo.toml --- rpc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 5e25b7901..0b7c17383 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -22,7 +22,7 @@ rustc-serialize = "0.3" serde_macros = { version = "0.6.13", optional = true } [build-dependencies] -serde_codegen = { "version" = "0.6.13", "optional" = true } +serde_codegen = { version = "0.6.13", optional = true } syntex = "0.29.0" [features] From 4f6bff1c47d6be087638623e0b396140e6b51e65 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 19 Feb 2016 11:39:36 +0100 Subject: [PATCH 21/23] Kill bad test. --- ethcore/src/service.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ethcore/src/service.rs b/ethcore/src/service.rs index 5e68efae9..2fc246025 100644 --- a/ethcore/src/service.rs +++ b/ethcore/src/service.rs @@ -124,6 +124,8 @@ impl IoHandler for ClientIoHandler { } } +// TODO: rewrite into something that doesn't dependent on the testing environment having a particular port ready for use. +/* #[cfg(test)] mod tests { use super::*; @@ -138,3 +140,4 @@ mod tests { assert!(service.is_ok()); } } +*/ \ No newline at end of file From 33b649bb0174db2d60fd7d9325ced186d2cdb0b1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 19 Feb 2016 11:57:04 +0100 Subject: [PATCH 22/23] Update script. --- install-deps.sh | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/install-deps.sh b/install-deps.sh index 774d18720..214b6748c 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -346,8 +346,7 @@ function run_installer() exe brew install rocksdb info "Installing multirust" exe brew install multirust - sudo multirust update nightly - sudo multirust default nightly + sudo multirust default beta echo } @@ -426,20 +425,20 @@ function run_installer() depFound=$((depFound+1)) check "multirust" isMultirust=true - if [[ $(multirust show-default 2>/dev/null | grep nightly | wc -l) == 4 ]]; then + if [[ $(multirust show-default 2>/dev/null | grep beta | wc -l) == 4 ]]; then depFound=$((depFound+1)) - check "rust nightly" - isMultirustNightly=true + check "rust beta" + isMultirustBeta=true else - uncheck "rust is not nightly" - isMultirustNightly=false - INSTALL_FILES+="${blue}${dim}==> multirust -> rust nightly:${reset}${n}" + uncheck "rust is not beta" + isMultirustBeta=false + INSTALL_FILES+="${blue}${dim}==> multirust -> rust beta:${reset}${n}" fi else uncheck "multirust is missing" - uncheck "rust nightly is missing" + uncheck "rust beta is missing" isMultirust=false - isMultirustNightly=false + isMultirustBeta=false INSTALL_FILES+="${blue}${dim}==> multirust:${reset}${n}" fi } @@ -626,10 +625,9 @@ function run_installer() echo fi - if [[ $isMultirustNightly == false ]]; then - info "Installing rust nightly..." - multirust update nightly - multirust default nightly + if [[ $isMultirustBeta == false ]]; then + info "Installing rust beta..." + multirust default beta echo fi } @@ -660,7 +658,7 @@ function run_installer() find_rocksdb find_multirust - if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then + if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustBeta == false ]]; then abort_install fi fi From 1cd76de8baa970b7f529caea1e9bf166f5555b6f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 19 Feb 2016 11:57:59 +0100 Subject: [PATCH 23/23] Update readme for betaUpdate readme for beta --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 40c8796e2..b840195d8 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,8 @@ apt-get install -y --force-yes librocksdb-dev # 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 +# install beta and make it default +multirust default beta # download and build parity git clone https://github.com/ethcore/parity @@ -47,12 +46,11 @@ sudo cp -a librocksdb.so* /usr/lib sudo ldconfig cd .. -# install rust nightly +# install rust beta curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes -# install nightly and make it default -sudo multirust update nightly -sudo multirust default nightly +# install beta and make it default +sudo multirust default beta # download and build parity git clone https://github.com/ethcore/parity @@ -68,8 +66,8 @@ brew update brew install rocksdb brew install multirust -# install nightly and make it default -multirust update nightly && multirust default nightly +# install beta and make it default +multirust default beta # download and build parity git clone https://github.com/ethcore/parity