From 1fd91108291613776963475db539c2e61077ee5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 1 Jun 2016 17:59:21 +0200 Subject: [PATCH 01/18] Serde bump --- Cargo.lock | 116 ++++++++++++++++++----------------------- Cargo.toml | 4 +- dapps/Cargo.toml | 6 +-- db/Cargo.toml | 2 +- ipc/codegen/Cargo.toml | 14 ++--- ipc/nano/Cargo.toml | 4 +- ipc/tests/Cargo.toml | 4 +- json/Cargo.toml | 2 +- rpc/Cargo.toml | 9 ++-- signer/Cargo.toml | 10 +--- 10 files changed, 74 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc2a8ef8c..a686b849e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,7 +21,7 @@ dependencies = [ "ethsync 1.2.0", "fdlimit 0.1.0", "hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "json-ipc-server 0.1.0 (git+https://github.com/ethcore/json-ipc-server.git)", + "json-ipc-server 0.1.0 (git+https://github.com/tomusdrw/json-ipc-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -29,7 +29,7 @@ dependencies = [ "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -57,10 +57,10 @@ dependencies = [ [[package]] name = "aster" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -257,7 +257,7 @@ dependencies = [ "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -269,8 +269,8 @@ dependencies = [ "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", + "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", + "jsonrpc-http-server 5.1.0", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)", "parity-dapps-builtins 0.5.0 (git+https://github.com/ethcore/parity-dapps-builtins-rs.git)", @@ -280,9 +280,9 @@ dependencies = [ "parity-dapps-wallet 0.5.0 (git+https://github.com/ethcore/parity-dapps-wallet-rs.git)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -307,11 +307,11 @@ dependencies = [ name = "ethcore-ipc-codegen" version = "1.2.0" dependencies = [ - "aster 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_codegen 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -319,7 +319,7 @@ name = "ethcore-ipc-nano" version = "1.2.0" dependencies = [ "ethcore-ipc 1.2.0", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", ] @@ -336,15 +336,15 @@ dependencies = [ "ethjson 0.1.0", "ethminer 1.2.0", "ethsync 1.2.0", - "json-ipc-server 0.1.0 (git+https://github.com/ethcore/json-ipc-server.git)", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git?branch=multiple_cors_domains)", + "json-ipc-server 0.1.0 (git+https://github.com/tomusdrw/json-ipc-server.git)", + "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", + "jsonrpc-http-server 5.1.0", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "transient-hashmap 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -356,14 +356,9 @@ dependencies = [ "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "ws 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -410,9 +405,9 @@ dependencies = [ "ethcore-util 1.2.0", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -579,10 +574,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "json-ipc-server" version = "0.1.0" -source = "git+https://github.com/ethcore/json-ipc-server.git#4f9226c4f84dcce2385a188374e3b5fc66b63e68" +source = "git+https://github.com/tomusdrw/json-ipc-server.git#7b632a7663c0cf109c914370840d795ebb0a6103" dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", "mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -598,31 +593,20 @@ dependencies = [ [[package]] name = "jsonrpc-core" version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/ethcore/jsonrpc-core.git#a1e871c7555bded9229dd7651de64a265231181f" dependencies = [ "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-http-server" version = "5.1.0" -source = "git+https://github.com/ethcore/jsonrpc-http-server.git#12f23b0cd85013ca980240b9d0206bf1fc9c909e" dependencies = [ "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "jsonrpc-http-server" -version = "5.1.0" -source = "git+https://github.com/ethcore/jsonrpc-http-server.git?branch=multiple_cors_domains#9c026feeb6573c82c99c8005c5d8244de68a2e30" -dependencies = [ - "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -875,15 +859,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "parity-dapps" version = "0.3.0" -source = "git+https://github.com/ethcore/parity-dapps-rs.git#01ff8c2a3e61ea436f0d47acbbb8ac4bea4cd234" +source = "git+https://github.com/ethcore/parity-dapps-rs.git#1f065d93aa49338e4a453c77c839957f2db78895" dependencies = [ - "aster 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_codegen 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1003,20 +987,20 @@ dependencies = [ [[package]] name = "quasi" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quasi_codegen" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aster 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1158,14 +1142,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_codegen" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aster 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_codegen 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1218,15 +1202,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syntex" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syntex_syntax" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index d7813468a..456409ba7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ build = "build.rs" [build-dependencies] rustc_version = "0.1" syntex = "*" -"ethcore-ipc-codegen" = { path = "ipc/codegen" } +ethcore-ipc-codegen = { path = "ipc/codegen" } [dependencies] log = "0.3" @@ -35,7 +35,7 @@ ethcore-dapps = { path = "dapps", optional = true } semver = "0.2" ethcore-ipc-nano = { path = "ipc/nano" } ethcore-ipc = { path = "ipc/rpc" } -json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } +json-ipc-server = { git = "https://github.com/tomusdrw/json-ipc-server.git" } ansi_term = "0.7" [dependencies.hyper] diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index 219904b4c..b7d752779 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -10,8 +10,8 @@ build = "build.rs" [dependencies] log = "0.3" -jsonrpc-core = "2.0" -jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git" } +jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } +jsonrpc-http-server = { path = "../../../workspace/jsonrpc-http-server" } hyper = { default-features = false, git = "https://github.com/ethcore/hyper" } url = "1.0" rustc-serialize = "0.3" @@ -31,7 +31,7 @@ clippy = { version = "0.0.69", optional = true} [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } -syntex = "0.32.0" +syntex = "*" [features] default = ["serde_codegen", "extra-dapps"] diff --git a/db/Cargo.toml b/db/Cargo.toml index 24d0e6fbe..b77840d02 100644 --- a/db/Cargo.toml +++ b/db/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Ethcore "] build = "build.rs" [build-dependencies] -syntex = "0.32" +syntex = "*" ethcore-ipc-codegen = { path = "../ipc/codegen" } [dependencies] diff --git a/ipc/codegen/Cargo.toml b/ipc/codegen/Cargo.toml index 78ca6a7b4..2febd1a2b 100644 --- a/ipc/codegen/Cargo.toml +++ b/ipc/codegen/Cargo.toml @@ -14,13 +14,13 @@ nightly-testing = ["clippy"] with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex", "syntex", "syntex_syntax"] [build-dependencies] -quasi_codegen = { version = "0.10", optional = true } -syntex = { version = "^0.31", optional = true } +quasi_codegen = { version = "0.11", optional = true } +syntex = { version = "*", optional = true } [dependencies] -aster = { version = "0.16", default-features = false } +aster = { version = "0.17", default-features = false } clippy = { version = "^0.*", optional = true } -quasi = { version = "0.10", default-features = false } -quasi_macros = { version = "0.10", optional = true } -syntex = { version = "0.32", optional = true } -syntex_syntax = { version = "0.32", optional = true } +quasi = { version = "0.11", default-features = false } +quasi_macros = { version = "0.11", optional = true } +syntex = { version = "*", optional = true } +syntex_syntax = { version = "*", optional = true } diff --git a/ipc/nano/Cargo.toml b/ipc/nano/Cargo.toml index fb68adeb7..b3260e6fc 100644 --- a/ipc/nano/Cargo.toml +++ b/ipc/nano/Cargo.toml @@ -7,8 +7,8 @@ license = "GPL-3.0" [features] [dependencies] -jsonrpc-core = "2.0" -"ethcore-ipc" = { path = "../rpc" } +jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } +ethcore-ipc = { path = "../rpc" } nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" } log = "0.3" diff --git a/ipc/tests/Cargo.toml b/ipc/tests/Cargo.toml index c3a0697c9..f7a5ee9bd 100644 --- a/ipc/tests/Cargo.toml +++ b/ipc/tests/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" path = "run.rs" [dependencies] -"ethcore-ipc" = { path = "../rpc" } +ethcore-ipc = { path = "../rpc" } ethcore-devtools = { path = "../../devtools" } semver = "0.2.0" nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" } @@ -17,4 +17,4 @@ ethcore-util = { path = "../../util" } [build-dependencies] syntex = "*" -"ethcore-ipc-codegen" = { path = "../codegen" } +ethcore-ipc-codegen = { path = "../codegen" } diff --git a/json/Cargo.toml b/json/Cargo.toml index 9c024c633..3c7810de8 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -14,7 +14,7 @@ clippy = { version = "0.0.69", optional = true} [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } -syntex = "0.32.0" +syntex = "*" [features] default = ["serde_codegen"] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 61b51cf88..815ed7b31 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -12,8 +12,9 @@ build = "build.rs" log = "0.3" serde = "0.7.0" serde_json = "0.7.0" -jsonrpc-core = "2.0" -jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git", branch = "multiple_cors_domains" } +jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } +# jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git", branch = "multiple_cors_domains" } +jsonrpc-http-server = { path = "../../../workspace/jsonrpc-http-server" } ethcore-util = { path = "../util" } ethcore = { path = "../ethcore" } ethash = { path = "../ethash" } @@ -25,11 +26,11 @@ rustc-serialize = "0.3" transient-hashmap = "0.1" serde_macros = { version = "0.7.0", optional = true } clippy = { version = "0.0.69", optional = true} -json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } +json-ipc-server = { git = "https://github.com/tomusdrw/json-ipc-server.git" } [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } -syntex = "^0.32.0" +syntex = "*" [features] default = ["serde_codegen"] diff --git a/signer/Cargo.toml b/signer/Cargo.toml index 51b1b1e8d..a311e03f6 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -9,24 +9,16 @@ build = "build.rs" [build-dependencies] rustc_version = "0.1" -serde_codegen = { version = "0.7.0", optional = true } -syntex = "^0.32.0" [dependencies] -serde = "0.7.0" -serde_json = "0.7.0" -rustc-serialize = "0.3" -jsonrpc-core = "2.0" +jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } log = "0.3" env_logger = "0.3" ws = "0.4.7" ethcore-util = { path = "../util" } ethcore-rpc = { path = "../rpc" } -serde_macros = { version = "0.7.0", optional = true } clippy = { version = "0.0.69", optional = true} [features] -default = ["serde_codegen"] -nightly = ["serde_macros"] dev = ["clippy"] From 4742860b2ecbcbc4f8cfd2148b72e8fb31bd6c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 1 Jun 2016 18:00:40 +0200 Subject: [PATCH 02/18] Using ethcore http server --- Cargo.lock | 5 +++-- dapps/Cargo.toml | 3 ++- rpc/Cargo.toml | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a686b849e..161b9d968 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ dependencies = [ "ethcore-util 1.2.0", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", - "jsonrpc-http-server 5.1.0", + "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)", "parity-dapps-builtins 0.5.0 (git+https://github.com/ethcore/parity-dapps-builtins-rs.git)", @@ -338,7 +338,7 @@ dependencies = [ "ethsync 1.2.0", "json-ipc-server 0.1.0 (git+https://github.com/tomusdrw/json-ipc-server.git)", "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", - "jsonrpc-http-server 5.1.0", + "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -604,6 +604,7 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" version = "5.1.0" +source = "git+https://github.com/ethcore/jsonrpc-http-server.git#7a4f322a31834737c8f007b00e7d376f7dc07cdb" dependencies = [ "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index b7d752779..3af7aac97 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -11,7 +11,8 @@ build = "build.rs" [dependencies] log = "0.3" jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } -jsonrpc-http-server = { path = "../../../workspace/jsonrpc-http-server" } +# jsonrpc-http-server = { path = "../../../workspace/jsonrpc-http-server" } +jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git" } hyper = { default-features = false, git = "https://github.com/ethcore/hyper" } url = "1.0" rustc-serialize = "0.3" diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 815ed7b31..1dfa1eeed 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -13,8 +13,8 @@ log = "0.3" serde = "0.7.0" serde_json = "0.7.0" jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } -# jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git", branch = "multiple_cors_domains" } -jsonrpc-http-server = { path = "../../../workspace/jsonrpc-http-server" } +jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git" } +# jsonrpc-http-server = { path = "../../../workspace/jsonrpc-http-server" } ethcore-util = { path = "../util" } ethcore = { path = "../ethcore" } ethash = { path = "../ethash" } From d601e11d59d68e9ae1e91c6df93e499b2475c021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 1 Jun 2016 18:40:44 +0200 Subject: [PATCH 03/18] Removing typeS --- Cargo.lock | 34 +++++++++++++++++----------------- dapps/src/rpc.rs | 4 ++-- signer/build.rs | 27 --------------------------- signer/src/lib.rs | 4 ---- signer/src/types/mod.rs | 23 ----------------------- signer/src/types/mod.rs.in | 25 ------------------------- 6 files changed, 19 insertions(+), 98 deletions(-) delete mode 100644 signer/src/types/mod.rs delete mode 100644 signer/src/types/mod.rs.in diff --git a/Cargo.lock b/Cargo.lock index 161b9d968..0542286ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,7 +72,7 @@ dependencies = [ "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -224,8 +224,8 @@ dependencies = [ "libc 0.2.10 (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.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -279,9 +279,9 @@ dependencies = [ "parity-dapps-status 0.5.0 (git+https://github.com/ethcore/parity-dapps-status-rs.git)", "parity-dapps-wallet 0.5.0 (git+https://github.com/ethcore/parity-dapps-wallet-rs.git)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -341,9 +341,9 @@ dependencies = [ "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "transient-hashmap 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -389,7 +389,7 @@ dependencies = [ "rust-crypto 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.1.0", "slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -404,9 +404,9 @@ version = "0.1.0" dependencies = [ "ethcore-util 1.2.0", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -593,11 +593,11 @@ dependencies = [ [[package]] name = "jsonrpc-core" version = "2.0.4" -source = "git+https://github.com/ethcore/jsonrpc-core.git#a1e871c7555bded9229dd7651de64a265231181f" +source = "git+https://github.com/ethcore/jsonrpc-core.git#2ffb194e05ada9ddbe3cc6111a431e07d167e672" dependencies = [ - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1138,7 +1138,7 @@ dependencies = [ [[package]] name = "serde" -version = "0.7.0" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1155,11 +1155,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/dapps/src/rpc.rs b/dapps/src/rpc.rs index 7ba0b9584..e282c0440 100644 --- a/dapps/src/rpc.rs +++ b/dapps/src/rpc.rs @@ -23,14 +23,14 @@ pub fn rpc(handler: Arc, panic_handler: Arc Box::new(RpcEndpoint { handler: handler, panic_handler: panic_handler, - cors_domain: Some(AccessControlAllowOrigin::Null) + cors_domain: vec![AccessControlAllowOrigin::Null], }) } struct RpcEndpoint { handler: Arc, panic_handler: Arc () + Send>>>>, - cors_domain: Option, + cors_domain: Vec, } impl Endpoint for RpcEndpoint { diff --git a/signer/build.rs b/signer/build.rs index 2bcfc7da5..41b9a1b3e 100644 --- a/signer/build.rs +++ b/signer/build.rs @@ -19,34 +19,7 @@ extern crate rustc_version; use rustc_version::{version_meta, Channel}; fn main() { - serde::main(); if let Channel::Nightly = version_meta().channel { println!("cargo:rustc-cfg=nightly"); } } - -#[cfg(not(feature = "serde_macros"))] -mod serde { - extern crate syntex; - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/types/mod.rs.in"); - let dst = Path::new(&out_dir).join("mod.rs"); - - let mut registry = syntex::Registry::new(); - - serde_codegen::register(&mut registry); - registry.expand("", &src, &dst).unwrap(); - } -} - -#[cfg(feature = "serde_macros")] -mod serde { - pub fn main() {} -} diff --git a/signer/src/lib.rs b/signer/src/lib.rs index f3a963ac7..49863ce79 100644 --- a/signer/src/lib.rs +++ b/signer/src/lib.rs @@ -17,8 +17,6 @@ #![warn(missing_docs)] #![cfg_attr(all(nightly, feature="dev"), feature(plugin))] #![cfg_attr(all(nightly, feature="dev"), plugin(clippy))] -// Generated by serde -#![cfg_attr(all(nightly, feature="dev"), allow(redundant_closure_call))] //! Signer module //! @@ -45,8 +43,6 @@ extern crate log; extern crate env_logger; -extern crate serde; -extern crate serde_json; extern crate rustc_serialize; extern crate ethcore_util as util; diff --git a/signer/src/types/mod.rs b/signer/src/types/mod.rs deleted file mode 100644 index d5e15046a..000000000 --- a/signer/src/types/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Reusable types with JSON Serialization. - -#[cfg(feature = "serde_macros")] -include!("mod.rs.in"); - -#[cfg(not(feature = "serde_macros"))] -include!(concat!(env!("OUT_DIR"), "/mod.rs")); diff --git a/signer/src/types/mod.rs.in b/signer/src/types/mod.rs.in deleted file mode 100644 index a59f81ece..000000000 --- a/signer/src/types/mod.rs.in +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - - - - - - - - - -// TODO [ToDr] Types are empty for now. But they are about to come. From a7a2b55362905a13c08fa6772038f946eadb1cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 1 Jun 2016 18:00:40 +0200 Subject: [PATCH 04/18] Using ethcore http server --- Cargo.lock | 83 ++++++++++++++++++++++++++------------ dapps/Cargo.toml | 4 +- dapps/src/rpc.rs | 4 +- ipc/nano/Cargo.toml | 2 +- rpc/Cargo.toml | 5 +-- signer/Cargo.toml | 2 +- signer/build.rs | 27 ------------- signer/src/lib.rs | 6 --- signer/src/types/mod.rs | 23 ----------- signer/src/types/mod.rs.in | 25 ------------ 10 files changed, 66 insertions(+), 115 deletions(-) delete mode 100644 signer/src/types/mod.rs delete mode 100644 signer/src/types/mod.rs.in diff --git a/Cargo.lock b/Cargo.lock index a686b849e..c53bad980 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,7 +72,7 @@ dependencies = [ "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -224,8 +224,8 @@ dependencies = [ "libc 0.2.10 (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.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -269,8 +269,8 @@ dependencies = [ "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", - "jsonrpc-http-server 5.1.0", + "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)", "parity-dapps-builtins 0.5.0 (git+https://github.com/ethcore/parity-dapps-builtins-rs.git)", @@ -279,9 +279,9 @@ dependencies = [ "parity-dapps-status 0.5.0 (git+https://github.com/ethcore/parity-dapps-status-rs.git)", "parity-dapps-wallet 0.5.0 (git+https://github.com/ethcore/parity-dapps-wallet-rs.git)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -319,7 +319,7 @@ name = "ethcore-ipc-nano" version = "1.2.0" dependencies = [ "ethcore-ipc 1.2.0", - "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", + "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", ] @@ -337,13 +337,13 @@ dependencies = [ "ethminer 1.2.0", "ethsync 1.2.0", "json-ipc-server 0.1.0 (git+https://github.com/tomusdrw/json-ipc-server.git)", - "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", - "jsonrpc-http-server 5.1.0", + "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "transient-hashmap 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -356,7 +356,7 @@ dependencies = [ "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", - "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", + "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "ws 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -389,7 +389,7 @@ dependencies = [ "rust-crypto 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.1.0", "slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -404,9 +404,9 @@ version = "0.1.0" dependencies = [ "ethcore-util 1.2.0", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -577,7 +577,7 @@ version = "0.1.0" source = "git+https://github.com/tomusdrw/json-ipc-server.git#7b632a7663c0cf109c914370840d795ebb0a6103" dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", + "jsonrpc-core 2.0.5 (git+https://github.com/ethcore/jsonrpc-core.git)", "mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -593,20 +593,32 @@ dependencies = [ [[package]] name = "jsonrpc-core" version = "2.0.4" -source = "git+https://github.com/ethcore/jsonrpc-core.git#a1e871c7555bded9229dd7651de64a265231181f" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jsonrpc-core" +version = "2.0.5" +source = "git+https://github.com/ethcore/jsonrpc-core.git#6717dd26b7a0fbac302fa4ea0fd195a22f3c85e5" +dependencies = [ + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-http-server" version = "5.1.0" +source = "git+https://github.com/ethcore/jsonrpc-http-server.git#7a4f322a31834737c8f007b00e7d376f7dc07cdb" dependencies = [ "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.0.4 (git+https://github.com/ethcore/jsonrpc-core.git)", + "jsonrpc-core 2.0.5 (git+https://github.com/ethcore/jsonrpc-core.git)", "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1137,7 +1149,7 @@ dependencies = [ [[package]] name = "serde" -version = "0.7.0" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1154,11 +1166,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1200,6 +1212,14 @@ name = "strsim" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "syntex" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syntex" version = "0.33.0" @@ -1208,6 +1228,19 @@ dependencies = [ "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex_syntax" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (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.33.0" diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index b7d752779..5372c74a9 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -10,8 +10,8 @@ build = "build.rs" [dependencies] log = "0.3" -jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } -jsonrpc-http-server = { path = "../../../workspace/jsonrpc-http-server" } +jsonrpc-core = "2.0" +jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git" } hyper = { default-features = false, git = "https://github.com/ethcore/hyper" } url = "1.0" rustc-serialize = "0.3" diff --git a/dapps/src/rpc.rs b/dapps/src/rpc.rs index 7ba0b9584..e282c0440 100644 --- a/dapps/src/rpc.rs +++ b/dapps/src/rpc.rs @@ -23,14 +23,14 @@ pub fn rpc(handler: Arc, panic_handler: Arc Box::new(RpcEndpoint { handler: handler, panic_handler: panic_handler, - cors_domain: Some(AccessControlAllowOrigin::Null) + cors_domain: vec![AccessControlAllowOrigin::Null], }) } struct RpcEndpoint { handler: Arc, panic_handler: Arc () + Send>>>>, - cors_domain: Option, + cors_domain: Vec, } impl Endpoint for RpcEndpoint { diff --git a/ipc/nano/Cargo.toml b/ipc/nano/Cargo.toml index b3260e6fc..fc229d393 100644 --- a/ipc/nano/Cargo.toml +++ b/ipc/nano/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" [features] [dependencies] -jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } +jsonrpc-core = "2.0" ethcore-ipc = { path = "../rpc" } nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" } log = "0.3" diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 815ed7b31..866221606 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -12,9 +12,8 @@ build = "build.rs" log = "0.3" serde = "0.7.0" serde_json = "0.7.0" -jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } -# jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git", branch = "multiple_cors_domains" } -jsonrpc-http-server = { path = "../../../workspace/jsonrpc-http-server" } +jsonrpc-core = "2.0" +jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git" } ethcore-util = { path = "../util" } ethcore = { path = "../ethcore" } ethash = { path = "../ethash" } diff --git a/signer/Cargo.toml b/signer/Cargo.toml index a311e03f6..170c9320e 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -11,7 +11,7 @@ build = "build.rs" rustc_version = "0.1" [dependencies] -jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc-core.git" } +jsonrpc-core = "2.0" log = "0.3" env_logger = "0.3" ws = "0.4.7" diff --git a/signer/build.rs b/signer/build.rs index 2bcfc7da5..41b9a1b3e 100644 --- a/signer/build.rs +++ b/signer/build.rs @@ -19,34 +19,7 @@ extern crate rustc_version; use rustc_version::{version_meta, Channel}; fn main() { - serde::main(); if let Channel::Nightly = version_meta().channel { println!("cargo:rustc-cfg=nightly"); } } - -#[cfg(not(feature = "serde_macros"))] -mod serde { - extern crate syntex; - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/types/mod.rs.in"); - let dst = Path::new(&out_dir).join("mod.rs"); - - let mut registry = syntex::Registry::new(); - - serde_codegen::register(&mut registry); - registry.expand("", &src, &dst).unwrap(); - } -} - -#[cfg(feature = "serde_macros")] -mod serde { - pub fn main() {} -} diff --git a/signer/src/lib.rs b/signer/src/lib.rs index f3a963ac7..c1fe3d308 100644 --- a/signer/src/lib.rs +++ b/signer/src/lib.rs @@ -17,8 +17,6 @@ #![warn(missing_docs)] #![cfg_attr(all(nightly, feature="dev"), feature(plugin))] #![cfg_attr(all(nightly, feature="dev"), plugin(clippy))] -// Generated by serde -#![cfg_attr(all(nightly, feature="dev"), allow(redundant_closure_call))] //! Signer module //! @@ -45,10 +43,6 @@ extern crate log; extern crate env_logger; -extern crate serde; -extern crate serde_json; -extern crate rustc_serialize; - extern crate ethcore_util as util; extern crate ethcore_rpc as rpc; extern crate jsonrpc_core; diff --git a/signer/src/types/mod.rs b/signer/src/types/mod.rs deleted file mode 100644 index d5e15046a..000000000 --- a/signer/src/types/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Reusable types with JSON Serialization. - -#[cfg(feature = "serde_macros")] -include!("mod.rs.in"); - -#[cfg(not(feature = "serde_macros"))] -include!(concat!(env!("OUT_DIR"), "/mod.rs")); diff --git a/signer/src/types/mod.rs.in b/signer/src/types/mod.rs.in deleted file mode 100644 index a59f81ece..000000000 --- a/signer/src/types/mod.rs.in +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - - - - - - - - - -// TODO [ToDr] Types are empty for now. But they are about to come. From 5f68b81f68c2dd846324390c67bfeaa893b42392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 1 Jun 2016 20:32:16 +0200 Subject: [PATCH 05/18] Updating jsonrpc-core --- Cargo.lock | 45 ++++++++++++--------------------------------- Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c53bad980..ab5b435a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,7 +21,7 @@ dependencies = [ "ethsync 1.2.0", "fdlimit 0.1.0", "hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "json-ipc-server 0.1.0 (git+https://github.com/tomusdrw/json-ipc-server.git)", + "json-ipc-server 0.1.0 (git+https://github.com/ethcore/json-ipc-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -269,7 +269,7 @@ dependencies = [ "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)", @@ -319,7 +319,7 @@ name = "ethcore-ipc-nano" version = "1.2.0" dependencies = [ "ethcore-ipc 1.2.0", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", ] @@ -336,8 +336,8 @@ dependencies = [ "ethjson 0.1.0", "ethminer 1.2.0", "ethsync 1.2.0", - "json-ipc-server 0.1.0 (git+https://github.com/tomusdrw/json-ipc-server.git)", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "json-ipc-server 0.1.0 (git+https://github.com/ethcore/json-ipc-server.git)", + "jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -356,7 +356,7 @@ dependencies = [ "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", - "jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "ws 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -574,10 +574,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "json-ipc-server" version = "0.1.0" -source = "git+https://github.com/tomusdrw/json-ipc-server.git#7b632a7663c0cf109c914370840d795ebb0a6103" +source = "git+https://github.com/ethcore/json-ipc-server.git#4f9226c4f84dcce2385a188374e3b5fc66b63e68" dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 2.0.5 (git+https://github.com/ethcore/jsonrpc-core.git)", + "jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -592,19 +592,19 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "2.0.5" +source = "git+https://github.com/ethcore/jsonrpc-core.git#6717dd26b7a0fbac302fa4ea0fd195a22f3c85e5" dependencies = [ "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-core" version = "2.0.5" -source = "git+https://github.com/ethcore/jsonrpc-core.git#6717dd26b7a0fbac302fa4ea0fd195a22f3c85e5" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1212,14 +1212,6 @@ name = "strsim" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "syntex" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syntex" version = "0.33.0" @@ -1228,19 +1220,6 @@ dependencies = [ "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "syntex_syntax" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (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.33.0" diff --git a/Cargo.toml b/Cargo.toml index 456409ba7..e93069c98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ ethcore-dapps = { path = "dapps", optional = true } semver = "0.2" ethcore-ipc-nano = { path = "ipc/nano" } ethcore-ipc = { path = "ipc/rpc" } -json-ipc-server = { git = "https://github.com/tomusdrw/json-ipc-server.git" } +json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } ansi_term = "0.7" [dependencies.hyper] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 866221606..8db7c0491 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -25,7 +25,7 @@ rustc-serialize = "0.3" transient-hashmap = "0.1" serde_macros = { version = "0.7.0", optional = true } clippy = { version = "0.0.69", optional = true} -json-ipc-server = { git = "https://github.com/tomusdrw/json-ipc-server.git" } +json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } From c202abe09d5c0734bf431fead695e58cd6738e83 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 2 Jun 2016 13:14:49 +0200 Subject: [PATCH 06/18] Switch RPC namespace form ethcore_ to trace_ --- parity/rpc_apis.rs | 4 +- rpc/src/v1/impls/ethcore.rs | 156 ++-------------------------- rpc/src/v1/impls/traces.rs | 157 +++++++++++++++++++++++++++-- rpc/src/v1/tests/mocked/ethcore.rs | 61 ++++------- rpc/src/v1/traits/ethcore.rs | 9 -- rpc/src/v1/traits/traces.rs | 10 ++ 6 files changed, 188 insertions(+), 209 deletions(-) diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index 143d6b48f..b54693582 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -153,10 +153,10 @@ pub fn setup_rpc(server: T, deps: Arc, apis: ApiSet } }, Api::Ethcore => { - server.add_delegate(EthcoreClient::new(&deps.client, &deps.miner, deps.logger.clone(), deps.settings.clone()).to_delegate()) + server.add_delegate(EthcoreClient::new(&deps.miner, deps.logger.clone(), deps.settings.clone()).to_delegate()) }, Api::Traces => { - server.add_delegate(TracesClient::new(&deps.client).to_delegate()) + server.add_delegate(TracesClient::new(&deps.client, &deps.miner).to_delegate()) }, Api::Rpc => { let modules = to_modules(&apis); diff --git a/rpc/src/v1/impls/ethcore.rs b/rpc/src/v1/impls/ethcore.rs index 69d036500..d9d5859d2 100644 --- a/rpc/src/v1/impls/ethcore.rs +++ b/rpc/src/v1/impls/ethcore.rs @@ -15,151 +15,39 @@ // along with Parity. If not, see . //! Ethcore-specific rpc implementation. -use util::{U256, Address, RotatingLogger, FixedHash, Uint}; +use util::{U256, Address, RotatingLogger, FixedHash}; use util::network_settings::NetworkSettings; use util::misc::version_data; use std::sync::{Arc, Weak}; use std::ops::Deref; use std::collections::BTreeMap; use jsonrpc_core::*; -use serde; use ethcore::miner::MinerService; -use ethcore::state_diff::StateDiff; -use ethcore::account_diff::{Diff, Existance}; -use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action}; -use ethcore::client::{BlockChainClient, CallAnalytics}; -use ethcore::trace::VMTrace; +use ethcore::client::{BlockChainClient}; use v1::traits::Ethcore; -use v1::types::{Bytes, CallRequest}; +use v1::types::{Bytes}; /// Ethcore implementation. -pub struct EthcoreClient where - C: BlockChainClient, +pub struct EthcoreClient where M: MinerService { - client: Weak, miner: Weak, logger: Arc, settings: Arc, } -impl EthcoreClient where C: BlockChainClient, M: MinerService { +impl EthcoreClient where M: MinerService { /// Creates new `EthcoreClient`. - pub fn new(client: &Arc, miner: &Arc, logger: Arc, settings: Arc) -> Self { + pub fn new(miner: &Arc, logger: Arc, settings: Arc) -> Self { EthcoreClient { - client: Arc::downgrade(client), miner: Arc::downgrade(miner), logger: logger, settings: settings, } } - - // TODO: share with eth.rs - fn sign_call(&self, request: CallRequest) -> Result { - let client = take_weak!(self.client); - let miner = take_weak!(self.miner); - let from = request.from.unwrap_or(Address::zero()); - Ok(EthTransaction { - nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)), - action: request.to.map_or(Action::Create, Action::Call), - gas: request.gas.unwrap_or(U256::from(50_000_000)), - gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()), - value: request.value.unwrap_or_else(U256::zero), - data: request.data.map_or_else(Vec::new, |d| d.to_vec()) - }.fake_sign(from)) - } } -fn vm_trace_to_object(t: &VMTrace) -> Value { - let mut ret = BTreeMap::new(); - ret.insert("code".to_owned(), to_value(&t.code).unwrap()); - - let mut subs = t.subs.iter(); - let mut next_sub = subs.next(); - - let ops = t.operations - .iter() - .enumerate() - .map(|(i, op)| { - let mut m = map![ - "pc".to_owned() => to_value(&op.pc).unwrap(), - "cost".to_owned() => match op.gas_cost <= U256::from(!0u64) { - true => to_value(&op.gas_cost.low_u64()), - false => to_value(&op.gas_cost), - }.unwrap() - ]; - if let Some(ref ex) = op.executed { - let mut em = map![ - "used".to_owned() => to_value(&ex.gas_used.low_u64()).unwrap(), - "push".to_owned() => to_value(&ex.stack_push).unwrap() - ]; - if let Some(ref md) = ex.mem_diff { - em.insert("mem".to_owned(), Value::Object(map![ - "off".to_owned() => to_value(&md.offset).unwrap(), - "data".to_owned() => to_value(&md.data).unwrap() - ])); - } - if let Some(ref sd) = ex.store_diff { - em.insert("store".to_owned(), Value::Object(map![ - "key".to_owned() => to_value(&sd.location).unwrap(), - "val".to_owned() => to_value(&sd.value).unwrap() - ])); - } - m.insert("ex".to_owned(), Value::Object(em)); - } - if next_sub.is_some() && next_sub.unwrap().parent_step == i { - m.insert("sub".to_owned(), vm_trace_to_object(next_sub.unwrap())); - next_sub = subs.next(); - } - Value::Object(m) - }) - .collect::>(); - ret.insert("ops".to_owned(), Value::Array(ops)); - Value::Object(ret) -} - -fn diff_to_object(d: &Diff) -> Value where T: serde::Serialize + Eq { - let mut ret = BTreeMap::new(); - match *d { - Diff::Same => { - ret.insert("diff".to_owned(), Value::String("=".to_owned())); - } - Diff::Born(ref x) => { - ret.insert("diff".to_owned(), Value::String("+".to_owned())); - ret.insert("+".to_owned(), to_value(x).unwrap()); - } - Diff::Died(ref x) => { - ret.insert("diff".to_owned(), Value::String("-".to_owned())); - ret.insert("-".to_owned(), to_value(x).unwrap()); - } - Diff::Changed(ref from, ref to) => { - ret.insert("diff".to_owned(), Value::String("*".to_owned())); - ret.insert("-".to_owned(), to_value(from).unwrap()); - ret.insert("+".to_owned(), to_value(to).unwrap()); - } - }; - Value::Object(ret) -} - -fn state_diff_to_object(t: &StateDiff) -> Value { - Value::Object(t.iter().map(|(address, account)| { - (address.hex(), Value::Object(map![ - "existance".to_owned() => Value::String(match account.existance() { - Existance::Born => "+", - Existance::Alive => ".", - Existance::Died => "-", - }.to_owned()), - "balance".to_owned() => diff_to_object(&account.balance), - "nonce".to_owned() => diff_to_object(&account.nonce), - "code".to_owned() => diff_to_object(&account.code), - "storage".to_owned() => Value::Object(account.storage.iter().map(|(key, val)| { - (key.hex(), diff_to_object(&val)) - }).collect::>()) - ])) - }).collect::>()) -} - -impl Ethcore for EthcoreClient where C: BlockChainClient + 'static, M: MinerService + 'static { +impl Ethcore for EthcoreClient where M: MinerService + 'static { fn set_min_gas_price(&self, params: Params) -> Result { from_params::<(U256,)>(params).and_then(|(gas_price,)| { @@ -249,34 +137,4 @@ impl Ethcore for EthcoreClient where C: BlockChainClient + 'static, let version = version_data(); to_value(&Bytes::new(version)) } - - fn vm_trace_call(&self, params: Params) -> Result { - trace!(target: "jsonrpc", "vm_trace_call: {:?}", params); - from_params(params) - .and_then(|(request,)| { - let signed = try!(self.sign_call(request)); - let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: true, state_diffing: false }); - if let Ok(executed) = r { - if let Some(vm_trace) = executed.vm_trace { - return Ok(vm_trace_to_object(&vm_trace)); - } - } - Ok(Value::Null) - }) - } - - fn state_diff_call(&self, params: Params) -> Result { - trace!(target: "jsonrpc", "state_diff_call: {:?}", params); - from_params(params) - .and_then(|(request,)| { - let signed = try!(self.sign_call(request)); - let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: false, state_diffing: true }); - if let Ok(executed) = r { - if let Some(state_diff) = executed.state_diff { - return Ok(state_diff_to_object(&state_diff)); - } - } - Ok(Value::Null) - }) - } } diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index 0008d0dc1..b6015d498 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -18,26 +18,139 @@ use std::sync::{Weak, Arc}; use jsonrpc_core::*; -use util::H256; -use ethcore::client::{BlockChainClient, TransactionID, TraceId}; +use std::collections::BTreeMap; +use util::{H256, U256, FixedHash, Uint}; +use serde; +use ethcore::client::{BlockChainClient, CallAnalytics, TransactionID, TraceId}; +use ethcore::trace::VMTrace; +use ethcore::miner::MinerService; +use ethcore::state_diff::StateDiff; +use ethcore::account_diff::{Diff, Existance}; +use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action}; use v1::traits::Traces; -use v1::types::{TraceFilter, Trace, BlockNumber, Index}; +use v1::types::{TraceFilter, Trace, BlockNumber, Index, CallRequest}; /// Traces api implementation. -pub struct TracesClient where C: BlockChainClient { +pub struct TracesClient where C: BlockChainClient, M: MinerService { client: Weak, + miner: Weak, } -impl TracesClient where C: BlockChainClient { +impl TracesClient where C: BlockChainClient, M: MinerService { /// Creates new Traces client. - pub fn new(client: &Arc) -> Self { + pub fn new(client: &Arc, miner: &Arc) -> Self { TracesClient { client: Arc::downgrade(client), + miner: Arc::downgrade(miner), } } + + // TODO: share with eth.rs + fn sign_call(&self, request: CallRequest) -> Result { + let client = take_weak!(self.client); + let miner = take_weak!(self.miner); + let from = request.from.unwrap_or(0.into()); + Ok(EthTransaction { + nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)), + action: request.to.map_or(Action::Create, Action::Call), + gas: request.gas.unwrap_or(50_000_000.into()), + gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()), + value: request.value.unwrap_or(0.into()), + data: request.data.map_or_else(Vec::new, |d| d.to_vec()) + }.fake_sign(from)) + } } -impl Traces for TracesClient where C: BlockChainClient + 'static { +fn vm_trace_to_object(t: &VMTrace) -> Value { + let mut ret = BTreeMap::new(); + ret.insert("code".to_owned(), to_value(&t.code).unwrap()); + + let mut subs = t.subs.iter(); + let mut next_sub = subs.next(); + + let ops = t.operations + .iter() + .enumerate() + .map(|(i, op)| { + let mut m = map![ + "pc".to_owned() => to_value(&op.pc).unwrap(), + "cost".to_owned() => match op.gas_cost <= U256::from(!0u64) { + true => to_value(&op.gas_cost.low_u64()), + false => to_value(&op.gas_cost), + }.unwrap() + ]; + if let Some(ref ex) = op.executed { + let mut em = map![ + "used".to_owned() => to_value(&ex.gas_used.low_u64()).unwrap(), + "push".to_owned() => to_value(&ex.stack_push).unwrap() + ]; + if let Some(ref md) = ex.mem_diff { + em.insert("mem".to_owned(), Value::Object(map![ + "off".to_owned() => to_value(&md.offset).unwrap(), + "data".to_owned() => to_value(&md.data).unwrap() + ])); + } + if let Some(ref sd) = ex.store_diff { + em.insert("store".to_owned(), Value::Object(map![ + "key".to_owned() => to_value(&sd.location).unwrap(), + "val".to_owned() => to_value(&sd.value).unwrap() + ])); + } + m.insert("ex".to_owned(), Value::Object(em)); + } + if next_sub.is_some() && next_sub.unwrap().parent_step == i { + m.insert("sub".to_owned(), vm_trace_to_object(next_sub.unwrap())); + next_sub = subs.next(); + } + Value::Object(m) + }) + .collect::>(); + ret.insert("ops".to_owned(), Value::Array(ops)); + Value::Object(ret) +} + +fn diff_to_object(d: &Diff) -> Value where T: serde::Serialize + Eq { + let mut ret = BTreeMap::new(); + match *d { + Diff::Same => { + ret.insert("diff".to_owned(), Value::String("=".to_owned())); + } + Diff::Born(ref x) => { + ret.insert("diff".to_owned(), Value::String("+".to_owned())); + ret.insert("+".to_owned(), to_value(x).unwrap()); + } + Diff::Died(ref x) => { + ret.insert("diff".to_owned(), Value::String("-".to_owned())); + ret.insert("-".to_owned(), to_value(x).unwrap()); + } + Diff::Changed(ref from, ref to) => { + ret.insert("diff".to_owned(), Value::String("*".to_owned())); + ret.insert("-".to_owned(), to_value(from).unwrap()); + ret.insert("+".to_owned(), to_value(to).unwrap()); + } + }; + Value::Object(ret) +} + +fn state_diff_to_object(t: &StateDiff) -> Value { + Value::Object(t.iter().map(|(address, account)| { + (address.hex(), Value::Object(map![ + "existance".to_owned() => Value::String(match account.existance() { + Existance::Born => "+", + Existance::Alive => ".", + Existance::Died => "-", + }.to_owned()), + "balance".to_owned() => diff_to_object(&account.balance), + "nonce".to_owned() => diff_to_object(&account.nonce), + "code".to_owned() => diff_to_object(&account.code), + "storage".to_owned() => Value::Object(account.storage.iter().map(|(key, val)| { + (key.hex(), diff_to_object(&val)) + }).collect::>()) + ])) + }).collect::>()) +} + +impl Traces for TracesClient where C: BlockChainClient + 'static, M: MinerService + 'static { fn filter(&self, params: Params) -> Result { from_params::<(TraceFilter,)>(params) .and_then(|(filter, )| { @@ -81,4 +194,34 @@ impl Traces for TracesClient where C: BlockChainClient + 'static { to_value(&trace) }) } + + fn vm_trace_call(&self, params: Params) -> Result { + trace!(target: "jsonrpc", "vm_trace_call: {:?}", params); + from_params(params) + .and_then(|(request,)| { + let signed = try!(self.sign_call(request)); + let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: true, state_diffing: false }); + if let Ok(executed) = r { + if let Some(vm_trace) = executed.vm_trace { + return Ok(vm_trace_to_object(&vm_trace)); + } + } + Ok(Value::Null) + }) + } + + fn state_diff_call(&self, params: Params) -> Result { + trace!(target: "jsonrpc", "state_diff_call: {:?}", params); + from_params(params) + .and_then(|(request,)| { + let signed = try!(self.sign_call(request)); + let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: false, state_diffing: true }); + if let Ok(executed) = r { + if let Some(state_diff) = executed.state_diff { + return Ok(state_diff_to_object(&state_diff)); + } + } + Ok(Value::Null) + }) + } } diff --git a/rpc/src/v1/tests/mocked/ethcore.rs b/rpc/src/v1/tests/mocked/ethcore.rs index 3bed1f0f0..1685a598b 100644 --- a/rpc/src/v1/tests/mocked/ethcore.rs +++ b/rpc/src/v1/tests/mocked/ethcore.rs @@ -18,7 +18,6 @@ use std::sync::Arc; use std::str::FromStr; use jsonrpc_core::IoHandler; use v1::{Ethcore, EthcoreClient}; -use ethcore::client::{TestBlockChainClient}; use ethcore::miner::MinerService; use v1::tests::helpers::TestMinerService; use util::numbers::*; @@ -26,11 +25,6 @@ use rustc_serialize::hex::FromHex; use util::log::RotatingLogger; use util::network_settings::NetworkSettings; -fn blockchain_client() -> Arc { - let client = TestBlockChainClient::new(); - Arc::new(client) -} - fn miner_service() -> Arc { Arc::new(TestMinerService::default()) } @@ -51,15 +45,14 @@ fn settings() -> Arc { }) } -fn ethcore_client(client: &Arc, miner: &Arc) -> EthcoreClient { - EthcoreClient::new(&client, &miner, logger(), settings()) +fn ethcore_client(miner: &Arc) -> EthcoreClient { + EthcoreClient::new(&miner, logger(), settings()) } #[test] fn rpc_ethcore_extra_data() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -75,8 +68,7 @@ fn rpc_ethcore_default_extra_data() { use util::ToPretty; let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -89,8 +81,7 @@ fn rpc_ethcore_default_extra_data() { #[test] fn rpc_ethcore_gas_floor_target() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -103,8 +94,7 @@ fn rpc_ethcore_gas_floor_target() { #[test] fn rpc_ethcore_min_gas_price() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -117,8 +107,7 @@ fn rpc_ethcore_min_gas_price() { #[test] fn rpc_ethcore_set_min_gas_price() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -132,8 +121,7 @@ fn rpc_ethcore_set_min_gas_price() { #[test] fn rpc_ethcore_set_gas_floor_target() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -147,8 +135,7 @@ fn rpc_ethcore_set_gas_floor_target() { #[test] fn rpc_ethcore_set_extra_data() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -162,8 +149,7 @@ fn rpc_ethcore_set_extra_data() { #[test] fn rpc_ethcore_set_author() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -177,11 +163,10 @@ fn rpc_ethcore_set_author() { #[test] fn rpc_ethcore_dev_logs() { let miner = miner_service(); - let client = blockchain_client(); let logger = logger(); logger.append("a".to_owned()); logger.append("b".to_owned()); - let ethcore = EthcoreClient::new(&client, &miner, logger.clone(), settings()).to_delegate(); + let ethcore = EthcoreClient::new(&miner, logger.clone(), settings()).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -194,8 +179,7 @@ fn rpc_ethcore_dev_logs() { #[test] fn rpc_ethcore_dev_logs_levels() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -207,8 +191,7 @@ fn rpc_ethcore_dev_logs_levels() { #[test] fn rpc_ethcore_set_transactions_limit() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -222,8 +205,7 @@ fn rpc_ethcore_set_transactions_limit() { #[test] fn rpc_ethcore_transactions_limit() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -236,8 +218,7 @@ fn rpc_ethcore_transactions_limit() { #[test] fn rpc_ethcore_net_chain() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -250,8 +231,7 @@ fn rpc_ethcore_net_chain() { #[test] fn rpc_ethcore_net_max_peers() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -264,8 +244,7 @@ fn rpc_ethcore_net_max_peers() { #[test] fn rpc_ethcore_net_port() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -278,8 +257,7 @@ fn rpc_ethcore_net_port() { #[test] fn rpc_ethcore_rpc_settings() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -292,8 +270,7 @@ fn rpc_ethcore_rpc_settings() { #[test] fn rpc_ethcore_node_name() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); diff --git a/rpc/src/v1/traits/ethcore.rs b/rpc/src/v1/traits/ethcore.rs index 116a4cd05..a0e12222a 100644 --- a/rpc/src/v1/traits/ethcore.rs +++ b/rpc/src/v1/traits/ethcore.rs @@ -72,12 +72,6 @@ pub trait Ethcore: Sized + Send + Sync + 'static { /// Returns default extra data fn default_extra_data(&self, _: Params) -> Result; - /// Executes the given call and returns the VM trace for it. - fn vm_trace_call(&self, _: Params) -> Result; - - /// Executes the given call and returns the diff for it. - fn state_diff_call(&self, params: Params) -> Result; - /// Should be used to convert object to io delegate. fn to_delegate(self) -> IoDelegate { let mut delegate = IoDelegate::new(Arc::new(self)); @@ -100,9 +94,6 @@ pub trait Ethcore: Sized + Send + Sync + 'static { delegate.add_method("ethcore_nodeName", Ethcore::node_name); delegate.add_method("ethcore_defaultExtraData", Ethcore::default_extra_data); - delegate.add_method("ethcore_vmTraceCall", Ethcore::vm_trace_call); - delegate.add_method("ethcore_stateDiffCall", Ethcore::state_diff_call); - delegate } } diff --git a/rpc/src/v1/traits/traces.rs b/rpc/src/v1/traits/traces.rs index 54d04b954..4b58b12ac 100644 --- a/rpc/src/v1/traits/traces.rs +++ b/rpc/src/v1/traits/traces.rs @@ -32,6 +32,12 @@ pub trait Traces: Sized + Send + Sync + 'static { /// Returns all traces produced at given block. fn block_traces(&self, _: Params) -> Result; + /// Executes the given call and returns the VM trace for it. + fn vm_trace_call(&self, _: Params) -> Result; + + /// Executes the given call and returns the diff for it. + fn state_diff_call(&self, params: Params) -> Result; + /// Should be used to convert object to io delegate. fn to_delegate(self) -> IoDelegate { let mut delegate = IoDelegate::new(Arc::new(self)); @@ -39,6 +45,10 @@ pub trait Traces: Sized + Send + Sync + 'static { delegate.add_method("trace_get", Traces::trace); delegate.add_method("trace_transaction", Traces::transaction_traces); delegate.add_method("trace_block", Traces::block_traces); + + delegate.add_method("trace_vmTraceCall", Traces::vm_trace_call); + delegate.add_method("trace_stateDiffCall", Traces::state_diff_call); + delegate } } From 3ba15f6c647f358174a5a42c9d1556c0c28597a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 2 Jun 2016 20:32:48 +0200 Subject: [PATCH 07/18] Updating httpserver and core --- Cargo.lock | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab5b435a4..e1f2a28b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -590,17 +590,6 @@ dependencies = [ "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "jsonrpc-core" -version = "2.0.5" -source = "git+https://github.com/ethcore/jsonrpc-core.git#6717dd26b7a0fbac302fa4ea0fd195a22f3c85e5" -dependencies = [ - "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "jsonrpc-core" version = "2.0.5" @@ -615,10 +604,10 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" version = "5.1.0" -source = "git+https://github.com/ethcore/jsonrpc-http-server.git#7a4f322a31834737c8f007b00e7d376f7dc07cdb" +source = "git+https://github.com/ethcore/jsonrpc-http-server.git#77dcac785c02c3a7622d36aa635ee80d63d0b20c" dependencies = [ "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.0.5 (git+https://github.com/ethcore/jsonrpc-core.git)", + "jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] From d7b79c12741f8d521f6edfa5b9dc75ce1a01a3a1 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Thu, 2 Jun 2016 20:34:38 +0200 Subject: [PATCH 08/18] don't return a state in state_at if the db prunes and the block is before guaranteed history --- ethcore/src/client/client.rs | 8 ++++++++ util/src/journaldb/archivedb.rs | 2 ++ util/src/journaldb/traits.rs | 3 +++ 3 files changed, 13 insertions(+) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 3ddf7018a..ced8c736c 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -371,6 +371,14 @@ impl Client where V: Verifier { return Some(self.state()) } + let block_number = self.block_number(id.clone()); + + // check that the block is not too old -- blocks within `HISTORY` blocks of the best will + // always be available. + if self.state_db.does_pruning() && self.best_block_number() >= block_number + HISTORY { + return None; + } + self.block_header(id).map(|header| { let db = self.state_db.lock().unwrap().boxed_clone(); State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce()) diff --git a/util/src/journaldb/archivedb.rs b/util/src/journaldb/archivedb.rs index b554db885..c79bab23e 100644 --- a/util/src/journaldb/archivedb.rs +++ b/util/src/journaldb/archivedb.rs @@ -175,6 +175,8 @@ impl JournalDB for ArchiveDB { fn state(&self, id: &H256) -> Option { self.backing.get_by_prefix(&id.bytes()[0..12]).and_then(|b| Some(b.to_vec())) } + + fn does_pruning(&self) -> bool { false } } #[cfg(test)] diff --git a/util/src/journaldb/traits.rs b/util/src/journaldb/traits.rs index 10212f976..d41077655 100644 --- a/util/src/journaldb/traits.rs +++ b/util/src/journaldb/traits.rs @@ -42,4 +42,7 @@ pub trait JournalDB : HashDB + Send + Sync { fn state(&self, _id: &H256) -> Option { None } + + /// Whether this database does pruning. + fn does_pruning(&self) -> bool { true } } From 6c6229c963260daf991586d3bb5df83fd01515df Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Thu, 2 Jun 2016 20:52:21 +0200 Subject: [PATCH 09/18] check if state root is valid for old blocks --- ethcore/src/client/client.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index ced8c736c..b9348c997 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -373,15 +373,18 @@ impl Client where V: Verifier { let block_number = self.block_number(id.clone()); - // check that the block is not too old -- blocks within `HISTORY` blocks of the best will - // always be available. - if self.state_db.does_pruning() && self.best_block_number() >= block_number + HISTORY { - return None; - } + self.block_header(id).and_then(|header| { + let root = HeaderView::new(&header).state_root(); + // check that the block is not too old -- blocks within `HISTORY` blocks of the best will + // always be available. If the block could be too old, check if its state root is valid. + if self.state_db.does_pruning() + && self.best_block_number() >= block_number + HISTORY + && self.state_db.exists(root) { + return None; + } - self.block_header(id).map(|header| { let db = self.state_db.lock().unwrap().boxed_clone(); - State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce()) + Some(State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce())) }) } From 1e10445f820fa9158581beece90e1d7b7c3d6206 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Thu, 2 Jun 2016 21:01:47 +0200 Subject: [PATCH 10/18] exists -> contains --- ethcore/src/client/client.rs | 14 +++++++++----- util/src/trie/triedb.rs | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index b9348c997..9fbe8ae2d 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -371,19 +371,23 @@ impl Client where V: Verifier { return Some(self.state()) } - let block_number = self.block_number(id.clone()); + let block_number = match self.block_number(id.clone()) { + Some(num) => num, + None => return None, + }; self.block_header(id).and_then(|header| { + let db = self.state_db.lock().unwrap().boxed_clone(); + let root = HeaderView::new(&header).state_root(); // check that the block is not too old -- blocks within `HISTORY` blocks of the best will // always be available. If the block could be too old, check if its state root is valid. - if self.state_db.does_pruning() - && self.best_block_number() >= block_number + HISTORY - && self.state_db.exists(root) { + if db.does_pruning() + && self.chain.best_block_number() >= block_number + HISTORY + && !db.contains(&root) { return None; } - let db = self.state_db.lock().unwrap().boxed_clone(); Some(State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce())) }) } diff --git a/util/src/trie/triedb.rs b/util/src/trie/triedb.rs index 06076d273..1c6d2236b 100644 --- a/util/src/trie/triedb.rs +++ b/util/src/trie/triedb.rs @@ -59,7 +59,7 @@ impl<'db> TrieDB<'db> { /// Create a new trie with the backing database `db` and `root` /// Panics, if `root` does not exist pub fn new(db: &'db HashDB, root: &'db H256) -> Self { - if !db.exists(root) { + if !db.contains(root) { flushln!("TrieDB::new({}): Trie root not found!", root); panic!("Trie root not found!"); } From ae2deaaf72b5418b56c35d6ba84239841d2055e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 3 Jun 2016 11:15:38 +0200 Subject: [PATCH 11/18] Bumping clippy version --- Cargo.lock | 31 +++++++++++++++++++++++-------- Cargo.toml | 2 +- dapps/Cargo.toml | 2 +- ethcore/Cargo.toml | 2 +- json/Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- signer/Cargo.toml | 2 +- sync/Cargo.toml | 2 +- util/Cargo.toml | 2 +- 9 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 723bca872..30cc49392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "parity" version = "1.2.0" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)", "daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", @@ -130,11 +130,26 @@ dependencies = [ [[package]] name = "clippy" -version = "0.0.69" +version = "0.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clippy_lints 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", + "quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "clippy_lints" +version = "0.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -241,7 +256,7 @@ name = "ethcore" version = "1.2.0" dependencies = [ "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.2.0", @@ -265,7 +280,7 @@ dependencies = [ name = "ethcore-dapps" version = "1.2.0" dependencies = [ - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", @@ -328,7 +343,7 @@ dependencies = [ name = "ethcore-rpc" version = "1.2.0" dependencies = [ - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.2.0", "ethcore 1.2.0", "ethcore-devtools 1.2.0", @@ -351,7 +366,7 @@ dependencies = [ name = "ethcore-signer" version = "1.2.0" dependencies = [ - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", @@ -368,7 +383,7 @@ dependencies = [ "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "bigint 0.1.0", "chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (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.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -413,7 +428,7 @@ dependencies = [ name = "ethsync" version = "1.2.0" dependencies = [ - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.2.0", "ethcore-util 1.2.0", diff --git a/Cargo.toml b/Cargo.toml index ce8823bd2..81deea136 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ daemonize = "0.2" num_cpus = "0.2" number_prefix = "0.2" rpassword = "0.2.1" -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} ethcore = { path = "ethcore" } ethcore-util = { path = "util" } ethsync = { path = "sync" } diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index 219904b4c..774c49de0 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -27,7 +27,7 @@ parity-dapps-builtins = { git = "https://github.com/ethcore/parity-dapps-builtin parity-dapps-wallet = { git = "https://github.com/ethcore/parity-dapps-wallet-rs.git", version = "0.5.0", optional = true } parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.3.0", optional = true } parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.2.0", optional = true } -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 1de24ee32..d558c902d 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -22,7 +22,7 @@ ethcore-util = { path = "../util" } evmjit = { path = "../evmjit", optional = true } ethash = { path = "../ethash" } num_cpus = "0.2" -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} crossbeam = "0.2.9" lazy_static = "0.1" ethcore-devtools = { path = "../devtools" } diff --git a/json/Cargo.toml b/json/Cargo.toml index 9c024c633..21327d284 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -10,7 +10,7 @@ rustc-serialize = "0.3" serde = "0.7.0" serde_json = "0.7.0" serde_macros = { version = "0.7.0", optional = true } -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 2dbefd7f4..ffc0272a0 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -23,7 +23,7 @@ ethcore-devtools = { path = "../devtools" } rustc-serialize = "0.3" transient-hashmap = "0.1" serde_macros = { version = "0.7.0", optional = true } -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } [build-dependencies] diff --git a/signer/Cargo.toml b/signer/Cargo.toml index 170c9320e..2efc4bb9c 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -18,7 +18,7 @@ ws = "0.4.7" ethcore-util = { path = "../util" } ethcore-rpc = { path = "../rpc" } -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} [features] dev = ["clippy"] diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 1b80e23fc..8c5b4c926 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Ethcore Date: Fri, 3 Jun 2016 11:36:30 +0200 Subject: [PATCH 12/18] Fixing warnings --- ethcore/src/evm/interpreter.rs | 1 - ethcore/src/executive.rs | 14 ++++++------ ethcore/src/trace/executive_tracer.rs | 6 ++--- ethcore/src/trace/mod.rs | 2 +- ethcore/src/trace/noop_tracer.rs | 2 +- parity/hypervisor/service.rs.in | 1 - sync/src/chain.rs | 19 +++++++-------- sync/src/lib.rs | 1 + util/src/hash.rs | 20 ++++++++-------- util/src/network/discovery.rs | 9 ++++---- util/src/network/host.rs | 33 ++++++++++++--------------- 11 files changed, 53 insertions(+), 55 deletions(-) diff --git a/ethcore/src/evm/interpreter.rs b/ethcore/src/evm/interpreter.rs index 1514b3e2e..5b97b66af 100644 --- a/ethcore/src/evm/interpreter.rs +++ b/ethcore/src/evm/interpreter.rs @@ -17,7 +17,6 @@ ///! Rust VM implementation use common::*; -use trace::VMTracer; use super::instructions as instructions; use super::instructions::{Instruction, get_info}; use std::marker::Copy; diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index 43864ee9e..f7615be09 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -81,14 +81,14 @@ impl<'a> Executive<'a> { } /// Creates `Externalities` from `Executive`. - pub fn as_externalities<'_, T, V>( - &'_ mut self, + pub fn as_externalities<'any, T, V>( + &'any mut self, origin_info: OriginInfo, - substate: &'_ mut Substate, - output: OutputPolicy<'_, '_>, - tracer: &'_ mut T, - vm_tracer: &'_ mut V - ) -> Externalities<'_, T, V> where T: Tracer, V: VMTracer { + substate: &'any mut Substate, + output: OutputPolicy<'any, 'any>, + tracer: &'any mut T, + vm_tracer: &'any mut V + ) -> Externalities<'any, T, V> where T: Tracer, V: VMTracer { Externalities::new(self.state, self.info, self.engine, self.vm_factory, self.depth, origin_info, substate, output, tracer, vm_tracer) } diff --git a/ethcore/src/trace/executive_tracer.rs b/ethcore/src/trace/executive_tracer.rs index a1a13cf43..ff7c6a62f 100644 --- a/ethcore/src/trace/executive_tracer.rs +++ b/ethcore/src/trace/executive_tracer.rs @@ -117,7 +117,7 @@ impl VMTracer for ExecutiveVMTracer { self.data.operations.push(VMOperation { pc: pc, instruction: instruction, - gas_cost: gas_cost.clone(), + gas_cost: gas_cost.clone(), executed: None, }); true @@ -133,10 +133,10 @@ impl VMTracer for ExecutiveVMTracer { self.data.operations.last_mut().expect("trace_executed is always called after a trace_prepare_execute").executed = Some(ex); } - fn prepare_subtrace(&self, code: &Bytes) -> Self { + fn prepare_subtrace(&self, code: &[u8]) -> Self { ExecutiveVMTracer { data: VMTrace { parent_step: self.data.operations.len(), - code: code.clone(), + code: code.to_vec(), operations: vec![], subs: vec![], }} diff --git a/ethcore/src/trace/mod.rs b/ethcore/src/trace/mod.rs index 53c062137..8f6c0b3f6 100644 --- a/ethcore/src/trace/mod.rs +++ b/ethcore/src/trace/mod.rs @@ -98,7 +98,7 @@ pub trait VMTracer: Send { fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem_diff: Option<(usize, &[u8])>, _store_diff: Option<(U256, U256)>) {} /// Spawn subtracer which will be used to trace deeper levels of execution. - fn prepare_subtrace(&self, code: &Bytes) -> Self where Self: Sized; + fn prepare_subtrace(&self, code: &[u8]) -> Self where Self: Sized; /// Spawn subtracer which will be used to trace deeper levels of execution. fn done_subtrace(&mut self, sub: Self) where Self: Sized; diff --git a/ethcore/src/trace/noop_tracer.rs b/ethcore/src/trace/noop_tracer.rs index ed0231b79..b6e6ca9fd 100644 --- a/ethcore/src/trace/noop_tracer.rs +++ b/ethcore/src/trace/noop_tracer.rs @@ -75,7 +75,7 @@ impl VMTracer for NoopVMTracer { fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem_diff: Option<(usize, &[u8])>, _store_diff: Option<(U256, U256)>) {} /// Spawn subtracer which will be used to trace deeper levels of execution. - fn prepare_subtrace(&self, _code: &Bytes) -> Self { NoopVMTracer } + fn prepare_subtrace(&self, _code: &[u8]) -> Self { NoopVMTracer } /// Spawn subtracer which will be used to trace deeper levels of execution. fn done_subtrace(&mut self, _sub: Self) {} diff --git a/parity/hypervisor/service.rs.in b/parity/hypervisor/service.rs.in index 12c39d90a..134194603 100644 --- a/parity/hypervisor/service.rs.in +++ b/parity/hypervisor/service.rs.in @@ -15,7 +15,6 @@ // along with Parity. If not, see . use std::sync::{RwLock,Arc}; -use std::ops::*; use ipc::IpcConfig; use std::collections::HashMap; use std::mem; diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 47c035daa..277be7fea 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -918,7 +918,7 @@ impl ChainSync { let skip: usize = try!(r.val_at(2)); let reverse: bool = try!(r.val_at(3)); let last = io.chain().chain_info().best_block_number; - let mut number = if try!(r.at(0)).size() == 32 { + let number = if try!(r.at(0)).size() == 32 { // id is a hash let hash: H256 = try!(r.val_at(0)); trace!(target: "sync", "-> GetBlockHeaders (hash: {}, max: {}, skip: {}, reverse:{})", hash, max_headers, skip, reverse); @@ -931,11 +931,11 @@ impl ChainSync { try!(r.val_at(0)) }; - if reverse { - number = min(last, number); + let mut number = if reverse { + min(last, number) } else { - number = max(0, number); - } + max(0, number) + }; let max_count = min(MAX_HEADERS_TO_SEND, max_headers); let mut count = 0; let mut data = Bytes::new(); @@ -1188,11 +1188,12 @@ impl ChainSync { let mut sent = 0; let last_parent = HeaderView::new(&io.chain().block_header(BlockID::Hash(chain_info.best_block_hash.clone())).unwrap()).parent_hash(); for (peer_id, peer_number) in lucky_peers { - let mut peer_best = self.peers.get(&peer_id).unwrap().latest_hash.clone(); - if chain_info.best_block_number - peer_number > MAX_PEER_LAG_PROPAGATION as BlockNumber { + let peer_best = if chain_info.best_block_number - peer_number > MAX_PEER_LAG_PROPAGATION as BlockNumber { // If we think peer is too far behind just send one latest hash - peer_best = last_parent.clone(); - } + last_parent.clone() + } else { + self.peers.get(&peer_id).unwrap().latest_hash.clone() + }; sent += match ChainSync::create_new_hashes_rlp(io.chain(), &peer_best, &chain_info.best_block_hash) { Some(rlp) => { { diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 9f69bb7da..9c7da71ab 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -162,6 +162,7 @@ impl NetworkProtocolHandler for EthSync { self.sync.write().unwrap().maintain_sync(&mut NetSyncIo::new(io, self.chain.deref())); } + #[cfg_attr(feature="dev", allow(single_match))] fn message(&self, io: &NetworkContext, message: &SyncMessage) { match *message { SyncMessage::NewChainBlocks { ref imported, ref invalid, ref enacted, ref retracted } => { diff --git a/util/src/hash.rs b/util/src/hash.rs index 1a16cefa4..acb4c5cc5 100644 --- a/util/src/hash.rs +++ b/util/src/hash.rs @@ -501,8 +501,8 @@ macro_rules! impl_hash { } } - impl<'_> From<&'_ str> for $from { - fn from(s: &'_ str) -> $from { + impl<'a> From<&'a str> for $from { + fn from(s: &'a str) -> $from { use std::str::FromStr; if s.len() % 2 == 1 { $from::from_str(&("0".to_owned() + &(clean_0x(s).to_owned()))[..]).unwrap_or_else(|_| $from::new()) @@ -524,8 +524,8 @@ impl From for H256 { } } -impl<'_> From<&'_ U256> for H256 { - fn from(value: &'_ U256) -> H256 { +impl<'a> From<&'a U256> for H256 { + fn from(value: &'a U256) -> H256 { unsafe { let mut ret: H256 = ::std::mem::uninitialized(); value.to_raw_bytes(&mut ret); @@ -540,8 +540,8 @@ impl From for U256 { } } -impl<'_> From<&'_ H256> for U256 { - fn from(value: &'_ H256) -> U256 { +impl<'a> From<&'a H256> for U256 { + fn from(value: &'a H256) -> U256 { U256::from(value.bytes()) } } @@ -566,8 +566,8 @@ impl From for H64 { } } /* -impl<'_> From<&'_ H256> for Address { - fn from(value: &'_ H256) -> Address { +impl<'a> From<&'a H256> for Address { + fn from(value: &'a H256) -> Address { unsafe { let mut ret: Address = ::std::mem::uninitialized(); ::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20); @@ -586,8 +586,8 @@ impl From
for H256 { } } -impl<'_> From<&'_ Address> for H256 { - fn from(value: &'_ Address) -> H256 { +impl<'a> From<&'a Address> for H256 { + fn from(value: &'a Address) -> H256 { unsafe { let mut ret = H256::new(); ::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20); diff --git a/util/src/network/discovery.rs b/util/src/network/discovery.rs index d65309246..b67110538 100644 --- a/util/src/network/discovery.rs +++ b/util/src/network/discovery.rs @@ -494,10 +494,11 @@ impl Discovery { } pub fn update_registration(&self, event_loop: &mut EventLoop) -> Result<(), NetworkError> { - let mut registration = EventSet::readable(); - if !self.send_queue.is_empty() { - registration = registration | EventSet::writable(); - } + let registration = if !self.send_queue.is_empty() { + EventSet::readable() | EventSet::writable() + } else { + EventSet::readable() + }; event_loop.reregister(&self.udp_socket, Token(self.token), registration, PollOpt::edge()).expect("Error reregistering UDP socket"); Ok(()) } diff --git a/util/src/network/host.rs b/util/src/network/host.rs index 92a912a40..fe139e383 100644 --- a/util/src/network/host.rs +++ b/util/src/network/host.rs @@ -712,28 +712,25 @@ impl Host where Message: Send + Sync + Clone { let mut failure_id = None; let mut deregister = false; let mut expired_session = None; - match token { - FIRST_SESSION ... LAST_SESSION => { - let sessions = self.sessions.write().unwrap(); - if let Some(session) = sessions.get(token).cloned() { - expired_session = Some(session.clone()); - let mut s = session.lock().unwrap(); - if !s.expired() { - if s.is_ready() { - for (p, _) in self.handlers.read().unwrap().iter() { - if s.have_capability(p) { - self.num_sessions.fetch_sub(1, AtomicOrdering::SeqCst); - to_disconnect.push(p); - } + if let FIRST_SESSION ... LAST_SESSION = token { + let sessions = self.sessions.write().unwrap(); + if let Some(session) = sessions.get(token).cloned() { + expired_session = Some(session.clone()); + let mut s = session.lock().unwrap(); + if !s.expired() { + if s.is_ready() { + for (p, _) in self.handlers.read().unwrap().iter() { + if s.have_capability(p) { + self.num_sessions.fetch_sub(1, AtomicOrdering::SeqCst); + to_disconnect.push(p); } } - s.set_expired(); - failure_id = s.id().cloned(); } - deregister = remote || s.done(); + s.set_expired(); + failure_id = s.id().cloned(); } - }, - _ => {}, + deregister = remote || s.done(); + } } if let Some(id) = failure_id { if remote { From 6f850ebdacf6b7b68dac093b558a90d886e91c7e Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 3 Jun 2016 12:10:10 +0200 Subject: [PATCH 13/18] does_pruning -> is_pruned --- ethcore/src/client/client.rs | 2 +- util/src/journaldb/archivedb.rs | 2 +- util/src/journaldb/traits.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 9fbe8ae2d..f74fb33f5 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -382,7 +382,7 @@ impl Client where V: Verifier { let root = HeaderView::new(&header).state_root(); // check that the block is not too old -- blocks within `HISTORY` blocks of the best will // always be available. If the block could be too old, check if its state root is valid. - if db.does_pruning() + if db.is_pruned() && self.chain.best_block_number() >= block_number + HISTORY && !db.contains(&root) { return None; diff --git a/util/src/journaldb/archivedb.rs b/util/src/journaldb/archivedb.rs index c79bab23e..c6acc1280 100644 --- a/util/src/journaldb/archivedb.rs +++ b/util/src/journaldb/archivedb.rs @@ -176,7 +176,7 @@ impl JournalDB for ArchiveDB { self.backing.get_by_prefix(&id.bytes()[0..12]).and_then(|b| Some(b.to_vec())) } - fn does_pruning(&self) -> bool { false } + fn is_pruned(&self) -> bool { false } } #[cfg(test)] diff --git a/util/src/journaldb/traits.rs b/util/src/journaldb/traits.rs index d41077655..74149b062 100644 --- a/util/src/journaldb/traits.rs +++ b/util/src/journaldb/traits.rs @@ -43,6 +43,6 @@ pub trait JournalDB : HashDB + Send + Sync { None } - /// Whether this database does pruning. - fn does_pruning(&self) -> bool { true } + /// Whether this database is pruned. + fn is_pruned(&self) -> bool { true } } From aa465fa2cdbbeafa899b42ede17e879ad037d8ae Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 3 Jun 2016 12:15:27 +0200 Subject: [PATCH 14/18] conditional style fix --- ethcore/src/client/client.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index f74fb33f5..83b9e30ef 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -379,12 +379,11 @@ impl Client where V: Verifier { self.block_header(id).and_then(|header| { let db = self.state_db.lock().unwrap().boxed_clone(); - let root = HeaderView::new(&header).state_root(); // check that the block is not too old -- blocks within `HISTORY` blocks of the best will // always be available. If the block could be too old, check if its state root is valid. - if db.is_pruned() - && self.chain.best_block_number() >= block_number + HISTORY - && !db.contains(&root) { + let root = HeaderView::new(&header).state_root(); + let is_old = self.chain.best_block_number() >= block_number + HISTORY; + if db.is_pruned() && is_old && !db.contains(&root) { return None; } From e6921144dc62fc5f1b81ab7094a12221286b2779 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Sun, 5 Jun 2016 22:05:01 +0200 Subject: [PATCH 15/18] simplify conditional in state_at --- ethcore/src/client/client.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 83b9e30ef..65cb13e4c 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -379,11 +379,8 @@ impl Client where V: Verifier { self.block_header(id).and_then(|header| { let db = self.state_db.lock().unwrap().boxed_clone(); - // check that the block is not too old -- blocks within `HISTORY` blocks of the best will - // always be available. If the block could be too old, check if its state root is valid. - let root = HeaderView::new(&header).state_root(); - let is_old = self.chain.best_block_number() >= block_number + HISTORY; - if db.is_pruned() && is_old && !db.contains(&root) { + // TODO [rob]: refactor State::from_existing so we avoid doing redundant lookups. + if !db.contains(&root) { return None; } From 3dff5a9f3f8825e859f807a916766bbb4357dfa4 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Sun, 5 Jun 2016 22:14:25 +0200 Subject: [PATCH 16/18] add early exit for pruned blocks --- ethcore/src/client/client.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 65cb13e4c..008ca7860 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -379,6 +379,11 @@ impl Client where V: Verifier { self.block_header(id).and_then(|header| { let db = self.state_db.lock().unwrap().boxed_clone(); + // early exit for pruned blocks + if db.is_pruned() && self.chain.best_block_number() >= block_number + HISTORY { + return None; + } + // TODO [rob]: refactor State::from_existing so we avoid doing redundant lookups. if !db.contains(&root) { return None; From 64b74eae43628784fc9d6f2ef5d3a39fa57cf25a Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Sun, 5 Jun 2016 23:50:27 +0200 Subject: [PATCH 17/18] fix travis build --- ethcore/src/client/client.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 008ca7860..4e834e2f8 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -384,12 +384,14 @@ impl Client where V: Verifier { return None; } + let root = HeaderView::new(&header).state_root(); + // TODO [rob]: refactor State::from_existing so we avoid doing redundant lookups. if !db.contains(&root) { return None; } - Some(State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce())) + Some(State::from_existing(db, root, self.engine.account_start_nonce())) }) } From 67b9e08ff0268bc78a9d7476954086e3d9a08903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 6 Jun 2016 10:11:43 +0200 Subject: [PATCH 18/18] Ignoring tests --- ethcore/src/json_tests/chain.rs | 3 ++- ethcore/src/json_tests/homestead_chain.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ethcore/src/json_tests/chain.rs b/ethcore/src/json_tests/chain.rs index 53052d8dc..2bee5eb2a 100644 --- a/ethcore/src/json_tests/chain.rs +++ b/ethcore/src/json_tests/chain.rs @@ -85,7 +85,8 @@ declare_test!{BlockchainTests_bcForkStressTest, "BlockchainTests/bcForkStressTes declare_test!{BlockchainTests_bcForkUncle, "BlockchainTests/bcForkUncle"} declare_test!{BlockchainTests_bcGasPricerTest, "BlockchainTests/bcGasPricerTest"} declare_test!{BlockchainTests_bcInvalidHeaderTest, "BlockchainTests/bcInvalidHeaderTest"} -declare_test!{BlockchainTests_bcInvalidRLPTest, "BlockchainTests/bcInvalidRLPTest"} +// TODO [ToDr] Ignored because of incorrect JSON (https://github.com/ethereum/tests/pull/113) +declare_test!{ignore => BlockchainTests_bcInvalidRLPTest, "BlockchainTests/bcInvalidRLPTest"} declare_test!{BlockchainTests_bcMultiChainTest, "BlockchainTests/bcMultiChainTest"} declare_test!{BlockchainTests_bcRPC_API_Test, "BlockchainTests/bcRPC_API_Test"} declare_test!{BlockchainTests_bcStateTest, "BlockchainTests/bcStateTest"} diff --git a/ethcore/src/json_tests/homestead_chain.rs b/ethcore/src/json_tests/homestead_chain.rs index 7756840bc..8db8ad224 100644 --- a/ethcore/src/json_tests/homestead_chain.rs +++ b/ethcore/src/json_tests/homestead_chain.rs @@ -26,7 +26,8 @@ declare_test!{BlockchainTests_Homestead_bcBlockGasLimitTest, "BlockchainTests/Ho declare_test!{BlockchainTests_Homestead_bcForkStressTest, "BlockchainTests/Homestead/bcForkStressTest"} declare_test!{BlockchainTests_Homestead_bcGasPricerTest, "BlockchainTests/Homestead/bcGasPricerTest"} declare_test!{BlockchainTests_Homestead_bcInvalidHeaderTest, "BlockchainTests/Homestead/bcInvalidHeaderTest"} -declare_test!{BlockchainTests_Homestead_bcInvalidRLPTest, "BlockchainTests/Homestead/bcInvalidRLPTest"} +// TODO [ToDr] Ignored because of incorrect JSON (https://github.com/ethereum/tests/pull/113) +declare_test!{ignore => BlockchainTests_Homestead_bcInvalidRLPTest, "BlockchainTests/Homestead/bcInvalidRLPTest"} declare_test!{BlockchainTests_Homestead_bcMultiChainTest, "BlockchainTests/Homestead/bcMultiChainTest"} declare_test!{BlockchainTests_Homestead_bcRPC_API_Test, "BlockchainTests/Homestead/bcRPC_API_Test"} declare_test!{BlockchainTests_Homestead_bcStateTest, "BlockchainTests/Homestead/bcStateTest"}