From e7dc0bed1665a77367b437e281c9c61e7cc934fa Mon Sep 17 00:00:00 2001 From: Afri Schoedon <5chdn@users.noreply.github.com> Date: Thu, 26 Jul 2018 22:15:36 +0200 Subject: [PATCH] Backports to 2.0.1-beta (#9145) * parity-version: bump beta to 2.0.1 * ci: update version strings for snaps * Be more graceful on Aura difficulty validation (#9164) * Be more graceful on Aura difficulty validation * test: rejects_step_backwards * test: proposer_switching * test: rejects_future_block * test: reports_skipped * test: verify_empty_seal_steps * Remove node-health (#9119) * Remove node-health * Remove ntp_servers * Add --ntp-servers as legacy instead of removing it * Add --ntp-servers to deprecated args * Remove unused stuff * Remove _legacy_ntp_servers * parity: fix UserDefaults json parser (#9189) * parity: fix UserDefaults json parser * parity: use serde_derive for UserDefaults * parity: support deserialization of old UserDefault json format * parity: make UserDefaults serde backwards compatible * parity: tabify indentation in UserDefaults * Fix bugfix hard fork logic (#9138) * Fix bugfix hard fork logic * Remove dustProtectionTransition from bugfix category EIP-168 is not enabled by default * Remove unnecessary 'static * Disable per-sender limit for local transactions. (#9148) * Disable per-sender limit for local transactions. * Add a missing new line. * rpc: fix is_major_importing sync state condition (#9112) * rpc: fix is_major_importing sync state condition * rpc: fix informant printout when waiting for peers * fix verification in ethcore-sync collect_blocks (#9135) * docker: update hub dockerfile (#9173) * update Dockerfile for hub update to Ubuntu Xenial 16.04 fix cmake version * docker: fix tab indentation in hub dockerfile * rpc: fix broken merge * rcp: remove node_health leftover from merge * rpc: remove dapps leftover from merge --- Cargo.lock | 155 ++++----- Cargo.toml | 3 +- docker/hub/Dockerfile | 4 +- ethcore/src/engines/authority_round/mod.rs | 46 ++- ethcore/src/miner/miner.rs | 10 +- ethcore/src/spec/spec.rs | 24 +- miner/src/pool/scoring.rs | 4 + miner/src/pool/tests/mod.rs | 11 +- node-health/Cargo.toml | 18 -- node-health/src/health.rs | 122 ------- node-health/src/lib.rs | 49 --- node-health/src/time.rs | 357 --------------------- node-health/src/types.rs | 57 ---- parity/cli/mod.rs | 12 +- parity/cli/tests/config.toml | 1 - parity/configuration.rs | 11 - parity/deprecated.rs | 6 + parity/informant.rs | 14 +- parity/lib.rs | 1 - parity/params.rs | 2 +- parity/rpc_apis.rs | 5 - parity/run.rs | 59 +--- parity/user_defaults.rs | 179 ++++++----- rpc/Cargo.toml | 1 - rpc/src/lib.rs | 3 +- rpc/src/v1/helpers/block_import.rs | 13 +- rpc/src/v1/impls/light/parity.rs | 9 - rpc/src/v1/impls/parity.rs | 11 +- rpc/src/v1/tests/mocked/parity.rs | 27 -- rpc/src/v1/traits/parity.rs | 5 - scripts/gitlab-build.sh | 2 +- transaction-pool/src/pool.rs | 1 + transaction-pool/src/scoring.rs | 6 + transaction-pool/src/tests/helpers.rs | 4 + transaction-pool/src/tests/mod.rs | 27 ++ transaction-pool/src/transactions.rs | 2 +- util/version/Cargo.toml | 2 +- 37 files changed, 300 insertions(+), 963 deletions(-) delete mode 100644 node-health/Cargo.toml delete mode 100644 node-health/src/health.rs delete mode 100644 node-health/src/lib.rs delete mode 100644 node-health/src/time.rs delete mode 100644 node-health/src/types.rs diff --git a/Cargo.lock b/Cargo.lock index 330a3ea5692..994ec315f73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,7 +96,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -217,6 +217,14 @@ dependencies = [ "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cmake" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "common-types" version = "0.1.0" @@ -231,14 +239,6 @@ dependencies = [ "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "conv" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crossbeam" version = "0.3.2" @@ -328,11 +328,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "custom_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "daemonize" version = "0.2.3" @@ -362,7 +357,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -433,7 +428,7 @@ dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -477,7 +472,7 @@ dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types-serialize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "fixed-hash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -607,9 +602,9 @@ dependencies = [ "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rlp_derive 0.1.0", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "stats 0.1.0", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", @@ -703,7 +698,7 @@ dependencies = [ "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -741,7 +736,7 @@ dependencies = [ "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -774,7 +769,7 @@ dependencies = [ "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -852,7 +847,7 @@ dependencies = [ "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.0", "triehash-ethereum 0.2.0", ] @@ -882,7 +877,7 @@ dependencies = [ "ethereum-types-serialize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "fixed-hash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "uint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -891,7 +886,7 @@ name = "ethereum-types-serialize" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -900,7 +895,7 @@ version = "0.1.0" dependencies = [ "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -921,7 +916,7 @@ dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -936,7 +931,7 @@ dependencies = [ "panic_hook 0.1.0", "parity-wordlist 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -957,10 +952,10 @@ dependencies = [ "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -977,7 +972,7 @@ dependencies = [ "panic_hook 0.1.0", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1012,7 +1007,7 @@ dependencies = [ "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", @@ -1335,7 +1330,7 @@ source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11#6b972 dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1372,7 +1367,7 @@ source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11#6b972 dependencies = [ "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1794,39 +1789,11 @@ dependencies = [ "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "node-health" -version = "0.1.0" -dependencies = [ - "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "ntp 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-reactor 0.1.0", - "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nodrop" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "ntp" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "num" version = "0.1.42" @@ -1845,7 +1812,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1947,7 +1914,7 @@ source = "git+https://github.com/paritytech/parity-common#5f05acd90cf173f2e1ce47 name = "parity-clib" version = "1.12.0" dependencies = [ - "parity-ethereum 2.0.0", + "parity-ethereum 2.0.1", ] [[package]] @@ -1964,7 +1931,7 @@ dependencies = [ [[package]] name = "parity-ethereum" -version = "2.0.0" +version = "2.0.1" dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2002,7 +1969,6 @@ dependencies = [ "mem 0.1.0", "migration-rocksdb 0.1.0", "node-filter 1.12.0", - "node-health 0.1.0", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", @@ -2014,7 +1980,7 @@ dependencies = [ "parity-rpc 1.12.0", "parity-rpc-client 1.4.0", "parity-updater 1.12.0", - "parity-version 2.0.0", + "parity-version 2.0.1", "parity-whisper 0.1.0", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.1 (git+https://github.com/paritytech/parity-common)", @@ -2027,7 +1993,7 @@ dependencies = [ "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2089,7 +2055,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2148,13 +2114,12 @@ dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "multihash 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "node-health 0.1.0", "order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-reactor 0.1.0", "parity-updater 1.12.0", - "parity-version 2.0.0", + "parity-version 2.0.1", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2162,7 +2127,7 @@ dependencies = [ "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "stats 0.1.0", @@ -2186,7 +2151,7 @@ dependencies = [ "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-rpc 1.12.0", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2224,7 +2189,7 @@ dependencies = [ "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-hash-fetch 1.12.0", - "parity-version 2.0.0", + "parity-version 2.0.1", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.1 (git+https://github.com/paritytech/parity-common)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2235,7 +2200,7 @@ dependencies = [ [[package]] name = "parity-version" -version = "2.0.0" +version = "2.0.1" dependencies = [ "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", @@ -2273,11 +2238,11 @@ dependencies = [ "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2310,7 +2275,7 @@ dependencies = [ "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "petgraph 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2466,7 +2431,7 @@ dependencies = [ "hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "primal-bit 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "primal-estimate 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2499,7 +2464,7 @@ dependencies = [ "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", @@ -2566,7 +2531,7 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2794,7 +2759,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.37" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2822,7 +2787,7 @@ name = "serde_ignored" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2833,7 +2798,7 @@ dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2891,7 +2856,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "smallvec" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2900,7 +2865,7 @@ dependencies = [ [[package]] name = "snappy" version = "0.1.0" -source = "git+https://github.com/paritytech/rust-snappy#40ac9a0d9fd613e7f38df800a11a589b7296da73" +source = "git+https://github.com/paritytech/rust-snappy#798408ffef8f86dd51481673aca10f5348d7491b" dependencies = [ "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)", @@ -2909,9 +2874,9 @@ dependencies = [ [[package]] name = "snappy-sys" version = "0.1.0" -source = "git+https://github.com/paritytech/rust-snappy#40ac9a0d9fd613e7f38df800a11a589b7296da73" +source = "git+https://github.com/paritytech/rust-snappy#798408ffef8f86dd51481673aca10f5348d7491b" dependencies = [ - "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3271,7 +3236,7 @@ name = "toml" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3288,7 +3253,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.0", ] @@ -3536,7 +3501,7 @@ dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", "parity-whisper 0.1.0", - "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3641,7 +3606,7 @@ dependencies = [ "checksum chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cce36c92cb605414e9b824f866f5babe0a0368e39ea07393b9b63cf3844c0e6" "checksum cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d85ee025368e69063c420cbb2ed9f852cb03a5e69b73be021e65726ce03585b6" "checksum clap 2.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8f4a2b3bb7ef3c672d7c13d15613211d5a6976b6892c598b0fcb5d40765f19c2" -"checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" +"checksum cmake 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "95470235c31c726d72bf2e1f421adc1e65b9d561bf5529612cbe1a72da1467b3" "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" "checksum crossbeam-deque 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c1bdc73742c36f7f35ebcda81dbb33a7e0d33757d03a06d9ddca762712ec5ea2" @@ -3652,7 +3617,6 @@ dependencies = [ "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum ct-logs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61cd11fb222fecf889f4531855c614548e92e8bd2eb178e35296885df5ee9a7c" "checksum ctrlc 1.1.1 (git+https://github.com/paritytech/rust-ctrlc.git)" = "" -"checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum daemonize 0.2.3 (git+https://github.com/paritytech/daemonize)" = "" "checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" "checksum docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d8acd393692c503b168471874953a2531df0e9ab77d0b6bbc582395743300a4a" @@ -3745,7 +3709,6 @@ dependencies = [ "checksum nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" -"checksum ntp 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06b0d2de4a2cd60c3ac85c98a1fc23668bc97bef2b10b706bccd88efb229497d" "checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" "checksum num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "81b483ea42927c463e191802e7334556b48e7875297564c0e9951bd3a0ae53e3" "checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe" @@ -3814,7 +3777,7 @@ dependencies = [ "checksum sct 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1137b767bbe1c4d30656993bdd97422ed41255d9400b105d735f8c7d9e800632" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "d3bcee660dcde8f52c3765dd9ca5ee36b4bf35470a738eb0bd5a8752b0389645" +"checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920" "checksum serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "f1711ab8b208541fa8de00425f6a577d90f27bb60724d2bb5fd911314af9668f" "checksum serde_derive_internals 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89b340a48245bc03ddba31d0ff1709c118df90edc6adabaca4aac77aea181cce" "checksum serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "190e9765dcedb56be63b6e0993a006c7e3b071a016a304736e4a315dc01fb142" @@ -3828,7 +3791,7 @@ dependencies = [ "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" "checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" -"checksum smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8fcd03faf178110ab0334d74ca9631d77f94c8c11cc77fcb59538abf0025695d" +"checksum smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f90c5e5fe535e48807ab94fc611d323935f39d4660c52b26b96446a7b33aef10" "checksum snappy 0.1.0 (git+https://github.com/paritytech/rust-snappy)" = "" "checksum snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)" = "" "checksum socket2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "06dc9f86ee48652b7c80f3d254e3b9accb67a928c562c64d10d7b016d3d98dab" diff --git a/Cargo.toml b/Cargo.toml index 1032a845952..e085ca27601 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ description = "Parity Ethereum client" name = "parity-ethereum" # NOTE Make sure to update util/version/Cargo.toml as well -version = "2.0.0" +version = "2.0.1" license = "GPL-3.0" authors = ["Parity Technologies "] @@ -46,7 +46,6 @@ ethcore-transaction = { path = "ethcore/transaction" } ethereum-types = "0.3" node-filter = { path = "ethcore/node_filter" } ethkey = { path = "ethkey" } -node-health = { path = "node-health" } rlp = { git = "https://github.com/paritytech/parity-common" } rpc-cli = { path = "rpc_cli" } parity-hash-fetch = { path = "hash-fetch" } diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index c6d812446bf..49615850b34 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:14.04 +FROM ubuntu:xenial MAINTAINER Parity Technologies WORKDIR /build #ENV for build TAG @@ -41,7 +41,6 @@ cd /build&&git clone https://github.com/paritytech/parity && \ git pull&& \ git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ #cleanup Docker image @@ -52,6 +51,7 @@ cd /build&&git clone https://github.com/paritytech/parity && \ # add-apt-repository software-properties-common \ make \ + cmake \ curl \ wget \ git \ diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/src/engines/authority_round/mod.rs index e927f77b715..e32d213f0a3 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -1149,9 +1149,10 @@ impl Engine for AuthorityRound { // If empty step messages are enabled we will validate the messages in the seal, missing messages are not // reported as there's no way to tell whether the empty step message was never sent or simply not included. - if header.number() >= self.empty_steps_transition { - let validate_empty_steps = || -> Result<(), Error> { + let empty_steps_len = if header.number() >= self.empty_steps_transition { + let validate_empty_steps = || -> Result { let empty_steps = header_empty_steps(header)?; + let empty_steps_len = empty_steps.len(); for empty_step in empty_steps { if empty_step.step <= parent_step || empty_step.step >= step { Err(EngineError::InsufficientProof( @@ -1168,16 +1169,27 @@ impl Engine for AuthorityRound { format!("invalid empty step proof: {:?}", empty_step)))?; } } - Ok(()) + Ok(empty_steps_len) }; - if let err @ Err(_) = validate_empty_steps() { - self.validators.report_benign(header.author(), set_number, header.number()); - return err; + match validate_empty_steps() { + Ok(len) => len, + Err(err) => { + self.validators.report_benign(header.author(), set_number, header.number()); + return Err(err); + }, } - } else { self.report_skipped(header, step, parent_step, &*validators, set_number); + + 0 + }; + + if header.number() >= self.validate_score_transition { + let expected_difficulty = calculate_score(parent_step.into(), step.into(), empty_steps_len.into()); + if header.difficulty() != &expected_difficulty { + return Err(From::from(BlockError::InvalidDifficulty(Mismatch { expected: expected_difficulty, found: header.difficulty().clone() }))); + } } Ok(()) @@ -1412,7 +1424,7 @@ mod tests { use engines::{Seal, Engine, EngineError, EthEngine}; use engines::validator_set::TestSet; use error::{Error, ErrorKind}; - use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep}; + use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score}; #[test] fn has_valid_metadata() { @@ -1518,12 +1530,15 @@ mod tests { let engine = Spec::new_test_round().engine; - let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); // Two validators. // Spec starts with step 2. + header.set_difficulty(calculate_score(U256::from(0), U256::from(2), U256::zero())); + let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); header.set_seal(vec![encode(&2usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header).is_ok()); assert!(engine.verify_block_external(&header).is_err()); + header.set_difficulty(calculate_score(U256::from(0), U256::from(1), U256::zero())); + let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); header.set_seal(vec![encode(&1usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header).is_ok()); assert!(engine.verify_block_external(&header).is_ok()); @@ -1544,9 +1559,10 @@ mod tests { let engine = Spec::new_test_round().engine; - let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); // Two validators. // Spec starts with step 2. + header.set_difficulty(calculate_score(U256::from(0), U256::from(1), U256::zero())); + let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); header.set_seal(vec![encode(&1usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header).is_ok()); assert!(engine.verify_block_external(&header).is_ok()); @@ -1573,8 +1589,10 @@ mod tests { // Two validators. // Spec starts with step 2. header.set_seal(vec![encode(&5usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); + header.set_difficulty(calculate_score(U256::from(4), U256::from(5), U256::zero())); assert!(engine.verify_block_family(&header, &parent_header).is_ok()); header.set_seal(vec![encode(&3usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); + header.set_difficulty(calculate_score(U256::from(4), U256::from(3), U256::zero())); assert!(engine.verify_block_family(&header, &parent_header).is_err()); } @@ -1608,6 +1626,7 @@ mod tests { parent_header.set_seal(vec![encode(&1usize).into_vec()]); parent_header.set_gas_limit("222222".parse::().unwrap()); let mut header: Header = Header::default(); + header.set_difficulty(calculate_score(U256::from(1), U256::from(3), U256::zero())); header.set_gas_limit("222222".parse::().unwrap()); header.set_seal(vec![encode(&3usize).into_vec()]); @@ -1967,16 +1986,15 @@ mod tests { let empty_step3 = sealed_empty_step(engine, 3, &parent_header.hash()); let empty_steps = vec![empty_step2, empty_step3]; + header.set_difficulty(calculate_score(U256::from(0), U256::from(4), U256::from(2))); + let signature = tap.sign(addr1, Some("1".into()), header.bare_hash()).unwrap(); header.set_seal(vec![ encode(&4usize).into_vec(), encode(&(&*signature as &[u8])).into_vec(), ::rlp::encode_list(&empty_steps).into_vec(), ]); - assert!(match engine.verify_block_family(&header, &parent_header) { - Ok(_) => true, - _ => false, - }); + assert!(engine.verify_block_family(&header, &parent_header).is_ok()); } #[test] diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 16a20f8a007..1144d14981c 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -1055,10 +1055,12 @@ impl miner::MinerService for Miner { // refuse to seal the first block of the chain if it contains hard forks // which should be on by default. - if block.block().header().number() == 1 && self.engine.params().contains_bugfix_hard_fork() { - warn!("Your chain specification contains one or more hard forks which are required to be \ - on by default. Please remove these forks and start your chain again."); - return; + if block.block().header().number() == 1 { + if let Some(name) = self.engine.params().nonzero_bugfix_hard_fork() { + warn!("Your chain specification contains one or more hard forks which are required to be \ + on by default. Please remove these forks and start your chain again: {}.", name); + return; + } } match self.engine.seals_internally() { diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index e8c316be5f2..d88bdb83364 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -57,7 +57,7 @@ fn fmt_err(f: F) -> String { /// Parameters common to ethereum-like blockchains. /// NOTE: when adding bugfix hard-fork parameters, -/// add to `contains_bugfix_hard_fork` +/// add to `nonzero_bugfix_hard_fork` /// /// we define a "bugfix" hard fork as any hard fork which /// you would put on-by-default in a new chain. @@ -188,13 +188,21 @@ impl CommonParams { } } - /// Whether these params contain any bug-fix hard forks. - pub fn contains_bugfix_hard_fork(&self) -> bool { - self.eip98_transition != 0 && self.eip155_transition != 0 && - self.validate_receipts_transition != 0 && self.eip86_transition != 0 && - self.eip140_transition != 0 && self.eip210_transition != 0 && - self.eip211_transition != 0 && self.eip214_transition != 0 && - self.validate_chain_id_transition != 0 && self.dust_protection_transition != 0 + /// Return Some if the current parameters contain a bugfix hard fork not on block 0. + pub fn nonzero_bugfix_hard_fork(&self) -> Option<&str> { + if self.eip155_transition != 0 { + return Some("eip155Transition"); + } + + if self.validate_receipts_transition != 0 { + return Some("validateReceiptsTransition"); + } + + if self.validate_chain_id_transition != 0 { + return Some("validateChainIdTransition"); + } + + None } } diff --git a/miner/src/pool/scoring.rs b/miner/src/pool/scoring.rs index 3592204054d..dbe3c08f453 100644 --- a/miner/src/pool/scoring.rs +++ b/miner/src/pool/scoring.rs @@ -143,6 +143,10 @@ impl txpool::Scoring for NonceAndGasPrice { } } } + + fn should_ignore_sender_limit(&self, new: &VerifiedTransaction) -> bool { + new.priority().is_local() + } } #[cfg(test)] diff --git a/miner/src/pool/tests/mod.rs b/miner/src/pool/tests/mod.rs index b5cbaab6319..1f69355890c 100644 --- a/miner/src/pool/tests/mod.rs +++ b/miner/src/pool/tests/mod.rs @@ -116,12 +116,11 @@ fn should_never_drop_local_transactions_from_different_senders() { let r1 = txq.import(TestClient::new(), vec![tx1].local()); let r2 = txq.import(TestClient::new(), vec![tx2].local()); assert_eq!(r1, vec![Ok(())]); - // max-per-sender is reached, that's ok. - assert_eq!(r2, vec![Err(transaction::Error::LimitReached)]); - assert_eq!(txq.status().status.transaction_count, 1); + assert_eq!(r2, vec![Ok(())]); + assert_eq!(txq.status().status.transaction_count, 2); // then - assert_eq!(txq.next_nonce(TestClient::new(), &sender), Some(nonce + 1.into())); + assert_eq!(txq.next_nonce(TestClient::new(), &sender), Some(nonce + 2.into())); // when let tx1 = Tx::gas_price(2).signed(); @@ -134,8 +133,8 @@ fn should_never_drop_local_transactions_from_different_senders() { // then assert_eq!(res, vec![Ok(()), Ok(())]); assert_eq!(res2, vec![Ok(()), Ok(())]); - assert_eq!(txq.status().status.transaction_count, 5); - assert_eq!(txq.next_nonce(TestClient::new(), &sender), Some(nonce + 1.into())); + assert_eq!(txq.status().status.transaction_count, 6); + assert_eq!(txq.next_nonce(TestClient::new(), &sender), Some(nonce + 2.into())); } #[test] diff --git a/node-health/Cargo.toml b/node-health/Cargo.toml deleted file mode 100644 index 22432a5f390..00000000000 --- a/node-health/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "node-health" -description = "Node's health status" -version = "0.1.0" -license = "GPL-3.0" -authors = ["Parity Technologies "] - -[dependencies] -futures = "0.1" -futures-cpupool = "0.1" -log = "0.3" -ntp = "0.5.0" -parking_lot = "0.6" -serde = "1.0" -serde_derive = "1.0" -time = "0.1.35" - -parity-reactor = { path = "../util/reactor" } diff --git a/node-health/src/health.rs b/node-health/src/health.rs deleted file mode 100644 index 430061ea2bb..00000000000 --- a/node-health/src/health.rs +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Reporting node's health. - -use std::sync::Arc; -use std::time::Duration; -use futures::Future; -use futures::sync::oneshot; -use types::{HealthInfo, HealthStatus, Health}; -use time::{TimeChecker, MAX_DRIFT}; -use parity_reactor::Remote; -use parking_lot::Mutex; -use {SyncStatus}; - -const TIMEOUT: Duration = Duration::from_secs(5); -const PROOF: &str = "Only one closure is invoked."; - -/// A struct enabling you to query for node's health. -#[derive(Debug, Clone)] -pub struct NodeHealth { - sync_status: Arc, - time: TimeChecker, - remote: Remote, -} - -impl NodeHealth { - /// Creates new `NodeHealth`. - pub fn new(sync_status: Arc, time: TimeChecker, remote: Remote) -> Self { - NodeHealth { sync_status, time, remote, } - } - - /// Query latest health report. - pub fn health(&self) -> Box + Send> { - trace!(target: "dapps", "Checking node health."); - // Check timediff - let sync_status = self.sync_status.clone(); - let time = self.time.time_drift(); - let (tx, rx) = oneshot::channel(); - let tx = Arc::new(Mutex::new(Some(tx))); - let tx2 = tx.clone(); - self.remote.spawn_with_timeout( - move |_| time.then(move |result| { - let _ = tx.lock().take().expect(PROOF).send(Ok(result)); - Ok(()) - }), - TIMEOUT, - move || { - let _ = tx2.lock().take().expect(PROOF).send(Err(())); - }, - ); - - Box::new(rx.map_err(|err| { - warn!(target: "dapps", "Health request cancelled: {:?}", err); - }).and_then(move |time| { - // Check peers - let peers = { - let (connected, max) = sync_status.peers(); - let (status, message) = match connected { - 0 => { - (HealthStatus::Bad, "You are not connected to any peers. There is most likely some network issue. Fix connectivity.".into()) - }, - 1 => (HealthStatus::NeedsAttention, "You are connected to only one peer. Your node might not be reliable. Check your network connection.".into()), - _ => (HealthStatus::Ok, "".into()), - }; - HealthInfo { status, message, details: (connected, max) } - }; - - // Check sync - let sync = { - let is_syncing = sync_status.is_major_importing(); - let (status, message) = if is_syncing { - (HealthStatus::NeedsAttention, "Your node is still syncing, the values you see might be outdated. Wait until it's fully synced.".into()) - } else { - (HealthStatus::Ok, "".into()) - }; - HealthInfo { status, message, details: is_syncing } - }; - - // Check time - let time = { - let (status, message, details) = match time { - Ok(Ok(diff)) if diff < MAX_DRIFT && diff > -MAX_DRIFT => { - (HealthStatus::Ok, "".into(), diff) - }, - Ok(Ok(diff)) => { - (HealthStatus::Bad, format!( - "Your clock is not in sync. Detected difference is too big for the protocol to work: {}ms. Synchronize your clock.", - diff, - ), diff) - }, - Ok(Err(err)) => { - (HealthStatus::NeedsAttention, format!( - "Unable to reach time API: {}. Make sure that your clock is synchronized.", - err, - ), 0) - }, - Err(_) => { - (HealthStatus::NeedsAttention, "Time API request timed out. Make sure that the clock is synchronized.".into(), 0) - }, - }; - - HealthInfo { status, message, details, } - }; - - Ok(Health { peers, sync, time}) - })) - } -} diff --git a/node-health/src/lib.rs b/node-health/src/lib.rs deleted file mode 100644 index 13529004a6c..00000000000 --- a/node-health/src/lib.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Node Health status reporting. - -#![warn(missing_docs)] - -extern crate futures; -extern crate futures_cpupool; -extern crate ntp; -extern crate time as time_crate; -extern crate parity_reactor; -extern crate parking_lot; - -#[macro_use] -extern crate log; -#[macro_use] -extern crate serde_derive; - -mod health; -mod time; -mod types; - -pub use futures_cpupool::CpuPool; -pub use health::NodeHealth; -pub use types::{Health, HealthInfo, HealthStatus}; -pub use time::{TimeChecker, Error}; - -/// Indicates sync status -pub trait SyncStatus: ::std::fmt::Debug + Send + Sync { - /// Returns true if there is a major sync happening. - fn is_major_importing(&self) -> bool; - - /// Returns number of connected and ideal peers. - fn peers(&self) -> (usize, usize); -} diff --git a/node-health/src/time.rs b/node-health/src/time.rs deleted file mode 100644 index 9dfb3aa87f4..00000000000 --- a/node-health/src/time.rs +++ /dev/null @@ -1,357 +0,0 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Periodically checks node's time drift using [SNTP](https://tools.ietf.org/html/rfc1769). -//! -//! An NTP packet is sent to the server with a local timestamp, the server then completes the packet, yielding the -//! following timestamps: -//! -//! Timestamp Name ID When Generated -//! ------------------------------------------------------------ -//! Originate Timestamp T1 time request sent by client -//! Receive Timestamp T2 time request received at server -//! Transmit Timestamp T3 time reply sent by server -//! Destination Timestamp T4 time reply received at client -//! -//! The drift is defined as: -//! -//! drift = ((T2 - T1) + (T3 - T4)) / 2. -//! - -use std::io; -use std::{fmt, mem, time}; -use std::collections::VecDeque; -use std::sync::atomic::{self, AtomicUsize}; -use std::sync::Arc; - -use futures::{self, Future}; -use futures::future::{self, IntoFuture}; -use futures_cpupool::{CpuPool, CpuFuture}; -use ntp; -use parking_lot::RwLock; -use time_crate::{Duration, Timespec}; - -/// Time checker error. -#[derive(Debug, Clone, PartialEq)] -pub enum Error { - /// No servers are currently available for a query. - NoServersAvailable, - /// There was an error when trying to reach the NTP server. - Ntp(String), - /// IO error when reading NTP response. - Io(String), -} - -impl fmt::Display for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - use self::Error::*; - - match *self { - NoServersAvailable => write!(fmt, "No NTP servers available"), - Ntp(ref err) => write!(fmt, "NTP error: {}", err), - Io(ref err) => write!(fmt, "Connection Error: {}", err), - } - } -} - -impl From for Error { - fn from(err: io::Error) -> Self { Error::Io(format!("{}", err)) } -} - -impl From for Error { - fn from(err: ntp::errors::Error) -> Self { Error::Ntp(format!("{}", err)) } -} - -/// NTP time drift checker. -pub trait Ntp { - /// Returned Future. - type Future: IntoFuture; - - /// Returns the current time drift. - fn drift(&self) -> Self::Future; -} - -const SERVER_MAX_POLL_INTERVAL_SECS: u64 = 60; -#[derive(Debug)] -struct Server { - pub address: String, - next_call: RwLock, - failures: AtomicUsize, -} - -impl Server { - pub fn is_available(&self) -> bool { - *self.next_call.read() < time::Instant::now() - } - - pub fn report_success(&self) { - self.failures.store(0, atomic::Ordering::SeqCst); - self.update_next_call(1) - } - - pub fn report_failure(&self) { - let errors = self.failures.fetch_add(1, atomic::Ordering::SeqCst); - self.update_next_call(1 << errors) - } - - fn update_next_call(&self, delay: usize) { - *self.next_call.write() = time::Instant::now() + time::Duration::from_secs(delay as u64 * SERVER_MAX_POLL_INTERVAL_SECS); - } -} - -impl> From for Server { - fn from(t: T) -> Self { - Server { - address: t.as_ref().to_owned(), - next_call: RwLock::new(time::Instant::now()), - failures: Default::default(), - } - } -} - -/// NTP client using the SNTP algorithm for calculating drift. -#[derive(Clone)] -pub struct SimpleNtp { - addresses: Vec>, - pool: CpuPool, -} - -impl fmt::Debug for SimpleNtp { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f - .debug_struct("SimpleNtp") - .field("addresses", &self.addresses) - .finish() - } -} - -impl SimpleNtp { - fn new>(addresses: &[T], pool: CpuPool) -> SimpleNtp { - SimpleNtp { - addresses: addresses.iter().map(Server::from).map(Arc::new).collect(), - pool: pool, - } - } -} - -impl Ntp for SimpleNtp { - type Future = future::Either< - CpuFuture, - future::FutureResult, - >; - - fn drift(&self) -> Self::Future { - use self::future::Either::{A, B}; - - let server = self.addresses.iter().find(|server| server.is_available()); - server.map(|server| { - let server = server.clone(); - A(self.pool.spawn_fn(move || { - debug!(target: "dapps", "Fetching time from {}.", server.address); - - match ntp::request(&server.address) { - Ok(packet) => { - let dest_time = ::time_crate::now_utc().to_timespec(); - let orig_time = Timespec::from(packet.orig_time); - let recv_time = Timespec::from(packet.recv_time); - let transmit_time = Timespec::from(packet.transmit_time); - - let drift = ((recv_time - orig_time) + (transmit_time - dest_time)) / 2; - - server.report_success(); - Ok(drift) - }, - Err(err) => { - server.report_failure(); - Err(err.into()) - }, - } - })) - }).unwrap_or_else(|| B(future::err(Error::NoServersAvailable))) - } -} - -// NOTE In a positive scenario first results will be seen after: -// MAX_RESULTS * UPDATE_TIMEOUT_INCOMPLETE_SECS seconds. -const MAX_RESULTS: usize = 4; -const UPDATE_TIMEOUT_OK_SECS: u64 = 6 * 60 * 60; -const UPDATE_TIMEOUT_WARN_SECS: u64 = 15 * 60; -const UPDATE_TIMEOUT_ERR_SECS: u64 = 60; -const UPDATE_TIMEOUT_INCOMPLETE_SECS: u64 = 10; - -/// Maximal valid time drift. -pub const MAX_DRIFT: i64 = 10_000; - -type BoxFuture = Box + Send>; - -#[derive(Debug, Clone)] -/// A time checker. -pub struct TimeChecker { - ntp: N, - last_result: Arc>)>>, -} - -impl TimeChecker { - /// Creates new time checker given the NTP server address. - pub fn new>(ntp_addresses: &[T], pool: CpuPool) -> Self { - let last_result = Arc::new(RwLock::new( - // Assume everything is ok at the very beginning. - (time::Instant::now(), vec![Ok(0)].into()) - )); - - let ntp = SimpleNtp::new(ntp_addresses, pool); - - TimeChecker { - ntp, - last_result, - } - } -} - -impl TimeChecker where ::Future: Send + 'static { - /// Updates the time - pub fn update(&self) -> BoxFuture { - trace!(target: "dapps", "Updating time from NTP."); - let last_result = self.last_result.clone(); - Box::new(self.ntp.drift().into_future().then(move |res| { - let res = res.map(|d| d.num_milliseconds()); - - if let Err(Error::NoServersAvailable) = res { - debug!(target: "dapps", "No NTP servers available. Selecting an older result."); - return select_result(last_result.read().1.iter()); - } - - // Update the results. - let mut results = mem::replace(&mut last_result.write().1, VecDeque::new()); - let has_all_results = results.len() >= MAX_RESULTS; - let valid_till = time::Instant::now() + time::Duration::from_secs( - match res { - Ok(time) if has_all_results && time < MAX_DRIFT => UPDATE_TIMEOUT_OK_SECS, - Ok(_) if has_all_results => UPDATE_TIMEOUT_WARN_SECS, - Err(_) if has_all_results => UPDATE_TIMEOUT_ERR_SECS, - _ => UPDATE_TIMEOUT_INCOMPLETE_SECS, - } - ); - - trace!(target: "dapps", "New time drift received: {:?}", res); - // Push the result. - results.push_back(res); - while results.len() > MAX_RESULTS { - results.pop_front(); - } - - // Select a response and update last result. - let res = select_result(results.iter()); - *last_result.write() = (valid_till, results); - res - })) - } - - /// Returns a current time drift or error if last request to NTP server failed. - pub fn time_drift(&self) -> BoxFuture { - // return cached result - { - let res = self.last_result.read(); - if res.0 > time::Instant::now() { - return Box::new(futures::done(select_result(res.1.iter()))); - } - } - // or update and return result - self.update() - } -} - -fn select_result<'a, T: Iterator>>(results: T) -> Result { - let mut min = None; - for res in results { - min = Some(match (min.take(), res) { - (Some(Ok(min)), &Ok(ref new)) => Ok(::std::cmp::min(min, *new)), - (Some(Ok(old)), &Err(_)) => Ok(old), - (_, ref new) => (*new).clone(), - }) - } - - min.unwrap_or_else(|| Err(Error::Ntp("NTP server unavailable.".into()))) -} - -#[cfg(test)] -mod tests { - use std::sync::Arc; - use std::cell::{Cell, RefCell}; - use std::time::Instant; - use time::Duration; - use futures::{future, Future}; - use super::{Ntp, TimeChecker, Error}; - use parking_lot::RwLock; - - #[derive(Clone)] - struct FakeNtp(RefCell>, Cell); - impl FakeNtp { - fn new() -> FakeNtp { - FakeNtp( - RefCell::new(vec![Duration::milliseconds(150)]), - Cell::new(0)) - } - } - - impl Ntp for FakeNtp { - type Future = future::FutureResult; - - fn drift(&self) -> Self::Future { - self.1.set(self.1.get() + 1); - future::ok(self.0.borrow_mut().pop().expect("Unexpected call to drift().")) - } - } - - fn time_checker() -> TimeChecker { - let last_result = Arc::new(RwLock::new( - (Instant::now(), vec![Err(Error::Ntp("NTP server unavailable".into()))].into()) - )); - - TimeChecker { - ntp: FakeNtp::new(), - last_result: last_result, - } - } - - #[test] - fn should_fetch_time_on_start() { - // given - let time = time_checker(); - - // when - let diff = time.time_drift().wait().unwrap(); - - // then - assert_eq!(diff, 150); - assert_eq!(time.ntp.1.get(), 1); - } - - #[test] - fn should_not_fetch_twice_if_timeout_has_not_passed() { - // given - let time = time_checker(); - - // when - let diff1 = time.time_drift().wait().unwrap(); - let diff2 = time.time_drift().wait().unwrap(); - - // then - assert_eq!(diff1, 150); - assert_eq!(diff2, 150); - assert_eq!(time.ntp.1.get(), 1); - } -} diff --git a/node-health/src/types.rs b/node-health/src/types.rs deleted file mode 100644 index 76fd3682f96..00000000000 --- a/node-health/src/types.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Base health types. - -/// Health API endpoint status. -#[derive(Debug, PartialEq, Serialize)] -pub enum HealthStatus { - /// Everything's OK. - #[serde(rename = "ok")] - Ok, - /// Node health need attention - /// (the issue is not critical, but may need investigation) - #[serde(rename = "needsAttention")] - NeedsAttention, - /// There is something bad detected with the node. - #[serde(rename = "bad")] - Bad, -} - -/// Represents a single check in node health. -/// Cointains the status of that check and apropriate message and details. -#[derive(Debug, PartialEq, Serialize)] -#[serde(deny_unknown_fields)] -pub struct HealthInfo { - /// Check status. - pub status: HealthStatus, - /// Human-readable message. - pub message: String, - /// Technical details of the check. - pub details: T, -} - -/// Node Health status. -#[derive(Debug, PartialEq, Serialize)] -#[serde(deny_unknown_fields)] -pub struct Health { - /// Status of peers. - pub peers: HealthInfo<(usize, usize)>, - /// Sync status. - pub sync: HealthInfo, - /// Time diff info. - pub time: HealthInfo, -} diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 460a78d9b18..1eaa314f541 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -794,10 +794,6 @@ usage! { "--no-config", "Don't load a configuration file.", - ARG arg_ntp_servers: (String) = "0.parity.pool.ntp.org:123,1.parity.pool.ntp.org:123,2.parity.pool.ntp.org:123,3.parity.pool.ntp.org:123", or |c: &Config| c.misc.as_ref()?.ntp_servers.clone().map(|vec| vec.join(",")), - "--ntp-servers=[HOSTS]", - "Comma separated list of NTP servers to provide current time (host:port). Used to verify node health. Parity uses pool.ntp.org NTP servers; consider joining the pool: http://www.pool.ntp.org/join.html", - ARG arg_logging: (Option) = None, or |c: &Config| c.misc.as_ref()?.logging.clone(), "-l, --logging=[LOGGING]", "Specify the logging level. Must conform to the same format as RUST_LOG.", @@ -1077,6 +1073,10 @@ usage! { ARG arg_dapps_path: (Option) = None, or |c: &Config| c.dapps.as_ref()?._legacy_path.clone(), "--dapps-path=[PATH]", "Specify directory where dapps should be installed.", + + ARG arg_ntp_servers: (Option) = None, or |_| None, + "--ntp-servers=[HOSTS]", + "Does nothing; checking if clock is sync with NTP servers is now done on the UI.", } } @@ -1350,7 +1350,6 @@ struct Snapshots { #[derive(Default, Debug, PartialEq, Deserialize)] #[serde(deny_unknown_fields)] struct Misc { - ntp_servers: Option>, logging: Option, log_file: Option, color: Option, @@ -1818,7 +1817,7 @@ mod tests { flag_can_restart: false, // -- Miscellaneous Options - arg_ntp_servers: "0.parity.pool.ntp.org:123,1.parity.pool.ntp.org:123,2.parity.pool.ntp.org:123,3.parity.pool.ntp.org:123".into(), + arg_ntp_servers: None, flag_version: false, arg_logging: Some("own_tx=trace".into()), arg_log_file: Some("/var/log/parity.log".into()), @@ -2024,7 +2023,6 @@ mod tests { disable_periodic: Some(true), }), misc: Some(Misc { - ntp_servers: Some(vec!["0.parity.pool.ntp.org:123".into()]), logging: Some("own_tx=trace".into()), log_file: Some("/var/log/parity.log".into()), color: Some(true), diff --git a/parity/cli/tests/config.toml b/parity/cli/tests/config.toml index 245935de12e..bb47a57efe8 100644 --- a/parity/cli/tests/config.toml +++ b/parity/cli/tests/config.toml @@ -75,7 +75,6 @@ scale_verifiers = false disable_periodic = true [misc] -ntp_servers = ["0.parity.pool.ntp.org:123"] logging = "own_tx=trace" log_file = "/var/log/parity.log" color = true diff --git a/parity/configuration.rs b/parity/configuration.rs index f904c169c0f..52bcc40b218 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -348,7 +348,6 @@ impl Configuration { miner_options: self.miner_options()?, gas_price_percentile: self.args.arg_gas_price_percentile, poll_lifetime: self.args.arg_poll_lifetime, - ntp_servers: self.ntp_servers(), ws_conf: ws_conf, http_conf: http_conf, ipc_conf: ipc_conf, @@ -574,10 +573,6 @@ impl Configuration { }) } - fn ntp_servers(&self) -> Vec { - self.args.arg_ntp_servers.split(",").map(str::to_owned).collect() - } - fn secretstore_config(&self) -> Result { Ok(SecretStoreConfiguration { enabled: self.secretstore_enabled(), @@ -1368,12 +1363,6 @@ mod tests { miner_options: Default::default(), gas_price_percentile: 50, poll_lifetime: 60, - ntp_servers: vec![ - "0.parity.pool.ntp.org:123".into(), - "1.parity.pool.ntp.org:123".into(), - "2.parity.pool.ntp.org:123".into(), - "3.parity.pool.ntp.org:123".into(), - ], ws_conf: Default::default(), http_conf: Default::default(), ipc_conf: Default::default(), diff --git a/parity/deprecated.rs b/parity/deprecated.rs index 514e7d5d92d..91a872e2202 100644 --- a/parity/deprecated.rs +++ b/parity/deprecated.rs @@ -225,6 +225,10 @@ pub fn find_deprecated(args: &Args) -> Vec { result.push(Deprecated::Removed("--dapps-path")); } + if args.arg_ntp_servers.is_some() { + result.push(Deprecated::Removed("--ntp-servers")); + } + result } @@ -256,6 +260,7 @@ mod tests { args.arg_dapps_pass = Some(Default::default()); args.flag_dapps_apis_all = true; args.flag_fast_and_loose = true; + args.arg_ntp_servers = Some(Default::default()); args }), vec![ Deprecated::DoesNothing("--warp"), @@ -276,6 +281,7 @@ mod tests { Deprecated::Removed("--dapps-pass"), Deprecated::Replaced("--dapps-apis-all", "--jsonrpc-apis"), Deprecated::Removed("--fast-and-loose"), + Deprecated::Removed("--ntp-servers"), ]); } } diff --git a/parity/informant.rs b/parity/informant.rs index 6f1227592f7..d3489a52f3b 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -35,7 +35,7 @@ use io::{TimerToken, IoContext, IoHandler}; use light::Cache as LightDataCache; use light::client::{LightChainClient, LightChainNotify}; use number_prefix::{binary_prefix, Standalone, Prefixed}; -use parity_rpc::{is_major_importing}; +use parity_rpc::is_major_importing_or_waiting; use parity_rpc::informant::RpcStats; use ethereum_types::H256; use bytes::Bytes; @@ -128,7 +128,7 @@ impl InformantData for FullNodeInformantData { fn is_major_importing(&self) -> bool { let state = self.sync.as_ref().map(|sync| sync.status().state); - is_major_importing(state, self.client.queue_info()) + is_major_importing_or_waiting(state, self.client.queue_info(), false) } fn report(&self) -> Report { @@ -142,7 +142,8 @@ impl InformantData for FullNodeInformantData { cache_sizes.insert("queue", queue_info.mem_used); cache_sizes.insert("chain", blockchain_cache_info.total()); - let (importing, sync_info) = match (self.sync.as_ref(), self.net.as_ref()) { + let importing = self.is_major_importing(); + let sync_info = match (self.sync.as_ref(), self.net.as_ref()) { (Some(sync), Some(net)) => { let status = sync.status(); let num_peers_range = net.num_peers_range(); @@ -150,16 +151,15 @@ impl InformantData for FullNodeInformantData { cache_sizes.insert("sync", status.mem_used); - let importing = is_major_importing(Some(status.state), queue_info.clone()); - (importing, Some(SyncInfo { + Some(SyncInfo { last_imported_block_number: status.last_imported_block_number.unwrap_or(chain_info.best_block_number), last_imported_old_block_number: status.last_imported_old_block_number, num_peers: status.num_peers, max_peers: status.current_max_peers(num_peers_range.start, num_peers_range.end - 1), snapshot_sync: status.is_snapshot_syncing(), - })) + }) } - _ => (is_major_importing(self.sync.as_ref().map(|s| s.status().state), queue_info.clone()), None), + _ => None }; Report { diff --git a/parity/lib.rs b/parity/lib.rs index b1b385a1a31..93edd74982b 100644 --- a/parity/lib.rs +++ b/parity/lib.rs @@ -57,7 +57,6 @@ extern crate ethcore_transaction as transaction; extern crate ethereum_types; extern crate ethkey; extern crate kvdb; -extern crate node_health; extern crate panic_hook; extern crate parity_hash_fetch as hash_fetch; extern crate parity_ipfs_api; diff --git a/parity/params.rs b/parity/params.rs index 2227af3e9d2..2d1514a02d4 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -334,7 +334,7 @@ pub fn fatdb_switch_to_bool(switch: Switch, user_defaults: &UserDefaults, _algor } pub fn mode_switch_to_bool(switch: Option, user_defaults: &UserDefaults) -> Result { - Ok(switch.unwrap_or(user_defaults.mode.clone())) + Ok(switch.unwrap_or(user_defaults.mode().clone())) } #[cfg(test)] diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index cf9f6d2dd59..7ecbaee5f5f 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -34,7 +34,6 @@ use jsonrpc_core::{self as core, MetaIoHandler}; use light::client::LightChainClient; use light::{TransactionQueue as LightTransactionQueue, Cache as LightDataCache}; use miner::external::ExternalMiner; -use node_health::NodeHealth; use parity_reactor; use parity_rpc::dispatch::{FullDispatcher, LightDispatcher}; use parity_rpc::informant::{ActivityNotifier, ClientNotifier}; @@ -224,7 +223,6 @@ pub struct FullDependencies { pub settings: Arc, pub net_service: Arc, pub updater: Arc, - pub health: NodeHealth, pub geth_compatibility: bool, pub ws_address: Option, pub fetch: FetchClient, @@ -329,7 +327,6 @@ impl FullDependencies { self.sync.clone(), self.updater.clone(), self.net_service.clone(), - self.health.clone(), self.secret_store.clone(), self.logger.clone(), self.settings.clone(), @@ -430,7 +427,6 @@ pub struct LightDependencies { pub secret_store: Arc, pub logger: Arc, pub settings: Arc, - pub health: NodeHealth, pub on_demand: Arc<::light::on_demand::OnDemand>, pub cache: Arc>, pub transaction_queue: Arc>, @@ -544,7 +540,6 @@ impl LightDependencies { self.secret_store.clone(), self.logger.clone(), self.settings.clone(), - self.health.clone(), signer, self.ws_address.clone(), self.gas_price_percentile, diff --git a/parity/run.rs b/parity/run.rs index fb52d86798e..f9ff9611112 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -15,7 +15,6 @@ // along with Parity. If not, see . use std::any::Any; -use std::fmt; use std::sync::{Arc, Weak}; use std::time::{Duration, Instant}; use std::thread; @@ -42,7 +41,6 @@ use journaldb::Algorithm; use light::Cache as LightDataCache; use miner::external::ExternalMiner; use node_filter::NodeFilter; -use node_health; use parity_reactor::EventLoop; use parity_rpc::{Origin, Metadata, NetworkSettings, informant, is_major_importing}; use updater::{UpdatePolicy, Updater}; @@ -95,7 +93,6 @@ pub struct RunCmd { pub miner_options: MinerOptions, pub gas_price_percentile: usize, pub poll_lifetime: u32, - pub ntp_servers: Vec, pub ws_conf: rpc::WsConfiguration, pub http_conf: rpc::HttpConfiguration, pub ipc_conf: rpc::IpcConfiguration, @@ -287,28 +284,6 @@ fn execute_light_impl(cmd: RunCmd, logger: Arc) -> Result); - impl fmt::Debug for LightSyncStatus { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "Light Sync Status") - } - } - impl node_health::SyncStatus for LightSyncStatus { - fn is_major_importing(&self) -> bool { self.0.is_major_importing() } - fn peers(&self) -> (usize, usize) { - let peers = sync::LightSyncProvider::peer_numbers(&*self.0); - (peers.connected, peers.max) - } - } - - let sync_status = Arc::new(LightSyncStatus(light_sync.clone())); - node_health::NodeHealth::new( - sync_status.clone(), - node_health::TimeChecker::new(&cmd.ntp_servers, cpu_pool.clone()), - event_loop.remote(), - ) - }; // start RPCs let deps_for_rpc_apis = Arc::new(rpc_apis::LightDependencies { @@ -316,7 +291,6 @@ fn execute_light_impl(cmd: RunCmd, logger: Arc) -> Result(cmd: RunCmd, logger: Arc, on_client_rq: let secret_store = account_provider.clone(); let signer_service = Arc::new(signer::new_service(&cmd.ws_conf, &cmd.logger_config)); - // the dapps server - let node_health = { - let (sync, client) = (sync_provider.clone(), client.clone()); - - struct SyncStatus(Arc, Arc, sync::NetworkConfiguration); - impl fmt::Debug for SyncStatus { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "Dapps Sync Status") - } - } - impl node_health::SyncStatus for SyncStatus { - fn is_major_importing(&self) -> bool { - is_major_importing(Some(self.0.status().state), self.1.queue_info()) - } - fn peers(&self) -> (usize, usize) { - let status = self.0.status(); - (status.num_peers, status.current_max_peers(self.2.min_peers, self.2.max_peers) as usize) - } - } - - let sync_status = Arc::new(SyncStatus(sync, client, net_conf)); - node_health::NodeHealth::new( - sync_status.clone(), - node_health::TimeChecker::new(&cmd.ntp_servers, cpu_pool.clone()), - event_loop.remote(), - ) - }; - let deps_for_rpc_apis = Arc::new(rpc_apis::FullDependencies { signer_service: signer_service, snapshot: snapshot_service.clone(), client: client.clone(), sync: sync_provider.clone(), - health: node_health, net: manage_network.clone(), secret_store: secret_store, miner: miner.clone(), @@ -821,13 +766,13 @@ fn execute_impl(cmd: RunCmd, logger: Arc, on_client_rq: user_defaults.pruning = algorithm; user_defaults.tracing = tracing; user_defaults.fat_db = fat_db; - user_defaults.mode = mode; + user_defaults.set_mode(mode); user_defaults.save(&user_defaults_path)?; // tell client how to save the default mode if it gets changed. client.on_user_defaults_change(move |mode: Option| { if let Some(mode) = mode { - user_defaults.mode = mode; + user_defaults.set_mode(mode); } let _ = user_defaults.save(&user_defaults_path); // discard failures - there's nothing we can do }); diff --git a/parity/user_defaults.rs b/parity/user_defaults.rs index 5031886f298..5df50dd99d3 100644 --- a/parity/user_defaults.rs +++ b/parity/user_defaults.rs @@ -14,107 +14,130 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use std::fmt; use std::fs::File; use std::io::Write; use std::path::Path; -use std::collections::BTreeMap; use std::time::Duration; -use serde::{Serialize, Serializer, Deserialize, Deserializer}; -use serde::de::{Error, Visitor, MapAccess}; -use serde::de::value::MapAccessDeserializer; -use serde_json::Value; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::de::from_reader; use serde_json::ser::to_string; use journaldb::Algorithm; -use ethcore::client::Mode; +use ethcore::client::{Mode as ClientMode}; +#[derive(Clone)] +pub struct Seconds(Duration); + +impl Seconds { + pub fn value(&self) -> u64 { + self.0.as_secs() + } +} + +impl From for Seconds { + fn from(s: u64) -> Seconds { + Seconds(Duration::from_secs(s)) + } +} + +impl From for Seconds { + fn from(d: Duration) -> Seconds { + Seconds(d) + } +} + +impl Into for Seconds { + fn into(self) -> Duration { + self.0 + } +} + +impl Serialize for Seconds { + fn serialize(&self, serializer: S) -> Result { + serializer.serialize_u64(self.value()) + } +} + +impl<'de> Deserialize<'de> for Seconds { + fn deserialize>(deserializer: D) -> Result { + let secs = u64::deserialize(deserializer)?; + Ok(Seconds::from(secs)) + } +} + +#[derive(Clone, Serialize, Deserialize)] +#[serde(rename_all = "lowercase", tag = "mode")] +pub enum Mode { + Active, + Passive { + #[serde(rename = "mode.timeout")] + timeout: Seconds, + #[serde(rename = "mode.alarm")] + alarm: Seconds, + }, + Dark { + #[serde(rename = "mode.timeout")] + timeout: Seconds, + }, + Offline, +} + +impl Into for Mode { + fn into(self) -> ClientMode { + match self { + Mode::Active => ClientMode::Active, + Mode::Passive { timeout, alarm } => ClientMode::Passive(timeout.into(), alarm.into()), + Mode::Dark { timeout } => ClientMode::Dark(timeout.into()), + Mode::Offline => ClientMode::Off, + } + } +} + +impl From for Mode { + fn from(mode: ClientMode) -> Mode { + match mode { + ClientMode::Active => Mode::Active, + ClientMode::Passive(timeout, alarm) => Mode::Passive { timeout: timeout.into(), alarm: alarm.into() }, + ClientMode::Dark(timeout) => Mode::Dark { timeout: timeout.into() }, + ClientMode::Off => Mode::Offline, + } + } +} + +#[derive(Serialize, Deserialize)] pub struct UserDefaults { pub is_first_launch: bool, + #[serde(with = "algorithm_serde")] pub pruning: Algorithm, pub tracing: bool, pub fat_db: bool, - pub mode: Mode, + #[serde(flatten)] + mode: Mode, } -impl Serialize for UserDefaults { - fn serialize(&self, serializer: S) -> Result - where S: Serializer { - let mut map: BTreeMap = BTreeMap::new(); - map.insert("is_first_launch".into(), Value::Bool(self.is_first_launch)); - map.insert("pruning".into(), Value::String(self.pruning.as_str().into())); - map.insert("tracing".into(), Value::Bool(self.tracing)); - map.insert("fat_db".into(), Value::Bool(self.fat_db)); - let mode_str = match self.mode { - Mode::Off => "offline", - Mode::Dark(timeout) => { - map.insert("mode.timeout".into(), Value::Number(timeout.as_secs().into())); - "dark" - }, - Mode::Passive(timeout, alarm) => { - map.insert("mode.timeout".into(), Value::Number(timeout.as_secs().into())); - map.insert("mode.alarm".into(), Value::Number(alarm.as_secs().into())); - "passive" - }, - Mode::Active => "active", - }; - map.insert("mode".into(), Value::String(mode_str.into())); - - map.serialize(serializer) +impl UserDefaults { + pub fn mode(&self) -> ClientMode { + self.mode.clone().into() } -} -struct UserDefaultsVisitor; - -impl<'a> Deserialize<'a> for UserDefaults { - fn deserialize(deserializer: D) -> Result - where D: Deserializer<'a> { - deserializer.deserialize_any(UserDefaultsVisitor) + pub fn set_mode(&mut self, mode: ClientMode) { + self.mode = mode.into(); } } -impl<'a> Visitor<'a> for UserDefaultsVisitor { - type Value = UserDefaults; +mod algorithm_serde { + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + use serde::de::Error; + use journaldb::Algorithm; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - write!(formatter, "a valid UserDefaults object") + pub fn serialize(algorithm: &Algorithm, serializer: S) -> Result + where S: Serializer { + algorithm.as_str().serialize(serializer) } - fn visit_map(self, visitor: V) -> Result where V: MapAccess<'a> { - let mut map: BTreeMap = Deserialize::deserialize(MapAccessDeserializer::new(visitor))?; - let pruning: Value = map.remove("pruning").ok_or_else(|| Error::custom("missing pruning"))?; - let pruning = pruning.as_str().ok_or_else(|| Error::custom("invalid pruning value"))?; - let pruning = pruning.parse().map_err(|_| Error::custom("invalid pruning method"))?; - let tracing: Value = map.remove("tracing").ok_or_else(|| Error::custom("missing tracing"))?; - let tracing = tracing.as_bool().ok_or_else(|| Error::custom("invalid tracing value"))?; - let fat_db: Value = map.remove("fat_db").unwrap_or_else(|| Value::Bool(false)); - let fat_db = fat_db.as_bool().ok_or_else(|| Error::custom("invalid fat_db value"))?; - - let mode: Value = map.remove("mode").unwrap_or_else(|| Value::String("active".to_owned())); - let mode = match mode.as_str().ok_or_else(|| Error::custom("invalid mode value"))? { - "offline" => Mode::Off, - "dark" => { - let timeout = map.remove("mode.timeout").and_then(|v| v.as_u64()).ok_or_else(|| Error::custom("invalid/missing mode.timeout value"))?; - Mode::Dark(Duration::from_secs(timeout)) - }, - "passive" => { - let timeout = map.remove("mode.timeout").and_then(|v| v.as_u64()).ok_or_else(|| Error::custom("invalid/missing mode.timeout value"))?; - let alarm = map.remove("mode.alarm").and_then(|v| v.as_u64()).ok_or_else(|| Error::custom("invalid/missing mode.alarm value"))?; - Mode::Passive(Duration::from_secs(timeout), Duration::from_secs(alarm)) - }, - "active" => Mode::Active, - _ => { return Err(Error::custom("invalid mode value")); }, - }; - - let user_defaults = UserDefaults { - is_first_launch: false, - pruning: pruning, - tracing: tracing, - fat_db: fat_db, - mode: mode, - }; - - Ok(user_defaults) + pub fn deserialize<'de, D>(deserializer: D) -> Result + where D: Deserializer<'de> { + let pruning = String::deserialize(deserializer)?; + pruning.parse().map_err(|_| Error::custom("invalid pruning method")) } } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index d551d90c530..7e25871a350 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -54,7 +54,6 @@ ethkey = { path = "../ethkey" } ethstore = { path = "../ethstore" } fetch = { path = "../util/fetch" } keccak-hash = { git = "https://github.com/paritytech/parity-common" } -node-health = { path = "../node-health" } parity-reactor = { path = "../util/reactor" } parity-updater = { path = "../updater" } parity-version = { path = "../util/version" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index bef7d9effb4..96926700c06 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -60,7 +60,6 @@ extern crate ethkey; extern crate ethstore; extern crate fetch; extern crate keccak_hash as hash; -extern crate node_health; extern crate parity_reactor; extern crate parity_updater as updater; extern crate parity_version as version; @@ -119,7 +118,7 @@ pub use http::{ }; pub use v1::{NetworkSettings, Metadata, Origin, informant, dispatch, signer}; -pub use v1::block_import::is_major_importing; +pub use v1::block_import::{is_major_importing, is_major_importing_or_waiting}; pub use v1::extractors::{RpcExtractor, WsExtractor, WsStats, WsDispatcher}; pub use authcodes::{AuthCodes, TimeProvider}; pub use http_common::HttpMetaExtractor; diff --git a/rpc/src/v1/helpers/block_import.rs b/rpc/src/v1/helpers/block_import.rs index 9e947e5baa7..50a4ed8e006 100644 --- a/rpc/src/v1/helpers/block_import.rs +++ b/rpc/src/v1/helpers/block_import.rs @@ -19,16 +19,23 @@ use ethcore::client::BlockQueueInfo; use sync::SyncState; -/// Check if client is during major sync or during block import. -pub fn is_major_importing(sync_state: Option, queue_info: BlockQueueInfo) -> bool { +/// Check if client is during major sync or during block import and allows defining whether 'waiting for peers' should +/// be considered a syncing state. +pub fn is_major_importing_or_waiting(sync_state: Option, queue_info: BlockQueueInfo, waiting_is_syncing_state: bool) -> bool { let is_syncing_state = sync_state.map_or(false, |s| match s { - SyncState::Idle | SyncState::NewBlocks | SyncState::WaitingPeers => false, + SyncState::Idle | SyncState::NewBlocks => false, + SyncState::WaitingPeers if !waiting_is_syncing_state => false, _ => true, }); let is_verifying = queue_info.unverified_queue_size + queue_info.verified_queue_size > 3; is_verifying || is_syncing_state } +/// Check if client is during major sync or during block import. +pub fn is_major_importing(sync_state: Option, queue_info: BlockQueueInfo) -> bool { + is_major_importing_or_waiting(sync_state, queue_info, true) +} + #[cfg(test)] mod tests { use ethcore::client::BlockQueueInfo; diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index f9ec03cd378..e7dcbe9e9ab 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -26,7 +26,6 @@ use ethstore::random_phrase; use sync::LightSyncProvider; use ethcore::account_provider::AccountProvider; use ethcore_logger::RotatingLogger; -use node_health::{NodeHealth, Health}; use ethcore::ids::BlockId; use light::client::LightChainClient; @@ -56,7 +55,6 @@ pub struct ParityClient { accounts: Arc, logger: Arc, settings: Arc, - health: NodeHealth, signer: Option>, ws_address: Option, eip86_transition: u64, @@ -71,7 +69,6 @@ impl ParityClient { accounts: Arc, logger: Arc, settings: Arc, - health: NodeHealth, signer: Option>, ws_address: Option, gas_price_percentile: usize, @@ -81,7 +78,6 @@ impl ParityClient { accounts, logger, settings, - health, signer, ws_address, eip86_transition: client.eip86_transition(), @@ -432,9 +428,4 @@ impl Parity for ParityClient { fn call(&self, _meta: Self::Metadata, _requests: Vec, _block: Trailing) -> Result> { Err(errors::light_unimplemented(None)) } - - fn node_health(&self) -> BoxFuture { - Box::new(self.health.health() - .map_err(|err| errors::internal("Health API failure.", err))) - } } diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 93560836f9c..c4c2ac9dba8 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -32,10 +32,9 @@ use ethcore::ids::BlockId; use ethcore::miner::{self, MinerService}; use ethcore::state::StateInfo; use ethcore_logger::RotatingLogger; -use node_health::{NodeHealth, Health}; use updater::{Service as UpdateService}; use jsonrpc_core::{BoxFuture, Result}; -use jsonrpc_core::futures::{future, Future}; +use jsonrpc_core::futures::future; use jsonrpc_macros::Trailing; use v1::helpers::{self, errors, fake_sign, ipfs, SigningQueue, SignerService, NetworkSettings}; use v1::metadata::Metadata; @@ -58,7 +57,6 @@ pub struct ParityClient { updater: Arc, sync: Arc, net: Arc, - health: NodeHealth, accounts: Arc, logger: Arc, settings: Arc, @@ -77,7 +75,6 @@ impl ParityClient where sync: Arc, updater: Arc, net: Arc, - health: NodeHealth, accounts: Arc, logger: Arc, settings: Arc, @@ -91,7 +88,6 @@ impl ParityClient where sync, updater, net, - health, accounts, logger, settings, @@ -466,9 +462,4 @@ impl Parity for ParityClient where .map(|res| res.into_iter().map(|res| res.output.into()).collect()) .map_err(errors::call) } - - fn node_health(&self) -> BoxFuture { - Box::new(self.health.health() - .map_err(|err| errors::internal("Health API failure.", err))) - } } diff --git a/rpc/src/v1/tests/mocked/parity.rs b/rpc/src/v1/tests/mocked/parity.rs index ca241140640..300badd742d 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -21,8 +21,6 @@ use ethcore_logger::RotatingLogger; use ethereum_types::{Address, U256, H256}; use ethstore::ethkey::{Generator, Random}; use miner::pool::local_transactions::Status as LocalTransactionStatus; -use node_health::{self, NodeHealth}; -use parity_reactor; use sync::ManageNetwork; use jsonrpc_core::IoHandler; @@ -40,7 +38,6 @@ pub struct Dependencies { pub client: Arc, pub sync: Arc, pub updater: Arc, - pub health: NodeHealth, pub logger: Arc, pub settings: Arc, pub network: Arc, @@ -57,11 +54,6 @@ impl Dependencies { network_id: 3, num_peers: 120, })), - health: NodeHealth::new( - Arc::new(FakeSync), - node_health::TimeChecker::new::(&[], node_health::CpuPool::new(1)), - parity_reactor::Remote::new_sync(), - ), updater: Arc::new(TestUpdater::default()), logger: Arc::new(RotatingLogger::new("rpc=trace".to_owned())), settings: Arc::new(NetworkSettings { @@ -85,7 +77,6 @@ impl Dependencies { self.sync.clone(), self.updater.clone(), self.network.clone(), - self.health.clone(), self.accounts.clone(), self.logger.clone(), self.settings.clone(), @@ -107,13 +98,6 @@ impl Dependencies { } } -#[derive(Debug)] -struct FakeSync; -impl node_health::SyncStatus for FakeSync { - fn is_major_importing(&self) -> bool { false } - fn peers(&self) -> (usize, usize) { (4, 25) } -} - #[test] fn rpc_parity_accounts_info() { let deps = Dependencies::new(); @@ -554,14 +538,3 @@ fn rpc_parity_call() { assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } - -#[test] -fn rpc_parity_node_health() { - let deps = Dependencies::new(); - let io = deps.default_client(); - - let request = r#"{"jsonrpc": "2.0", "method": "parity_nodeHealth", "params":[], "id": 1}"#; - let response = r#"{"jsonrpc":"2.0","result":{"peers":{"details":[4,25],"message":"","status":"ok"},"sync":{"details":false,"message":"","status":"ok"},"time":{"details":0,"message":"","status":"ok"}},"id":1}"#; - - assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); -} diff --git a/rpc/src/v1/traits/parity.rs b/rpc/src/v1/traits/parity.rs index 2f2eef90741..1cc6aca9629 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -21,7 +21,6 @@ use std::collections::BTreeMap; use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_macros::Trailing; -use node_health::Health; use v1::types::{ H160, H256, H512, U256, U64, Bytes, CallRequest, Peers, Transaction, RpcSettings, Histogram, @@ -219,9 +218,5 @@ build_rpc_trait! { /// Call contract, returning the output data. #[rpc(meta, name = "parity_call")] fn call(&self, Self::Metadata, Vec, Trailing) -> Result>; - - /// Returns node's health report. - #[rpc(name = "parity_nodeHealth")] - fn node_health(&self) -> BoxFuture; } } diff --git a/scripts/gitlab-build.sh b/scripts/gitlab-build.sh index 3d7d392d81f..014cab8e622 100755 --- a/scripts/gitlab-build.sh +++ b/scripts/gitlab-build.sh @@ -198,7 +198,7 @@ case $BUILD_PLATFORM in snapcraft clean echo "Prepare snapcraft.yaml for build on Gitlab CI in Docker image" sed -i 's/git/'"$VER"'/g' snap/snapcraft.yaml - if [[ "$CI_BUILD_REF_NAME" = "stable" || "$CI_BUILD_REF_NAME" = "beta" || "$VER" == *1.10* || "$VER" == *1.11* ]]; + if [[ "$CI_BUILD_REF_NAME" = "stable" || "$CI_BUILD_REF_NAME" = "beta" || "$VER" == *1.11* || "$VER" == *2.0* ]]; then sed -i -e 's/grade: devel/grade: stable/' snap/snapcraft.yaml; fi diff --git a/transaction-pool/src/pool.rs b/transaction-pool/src/pool.rs index e2fa36c0e54..c94b736b8ff 100644 --- a/transaction-pool/src/pool.rs +++ b/transaction-pool/src/pool.rs @@ -613,3 +613,4 @@ impl<'a, T, R, S, L> Iterator for PendingIterator<'a, T, R, S, L> where None } } + diff --git a/transaction-pool/src/scoring.rs b/transaction-pool/src/scoring.rs index 390e016af93..25189604cd2 100644 --- a/transaction-pool/src/scoring.rs +++ b/transaction-pool/src/scoring.rs @@ -102,6 +102,12 @@ pub trait Scoring: fmt::Debug { /// /// NOTE returning `InsertNew` here can lead to some transactions being accepted above pool limits. fn should_replace(&self, old: &T, new: &T) -> Choice; + + /// Decides if the transaction should ignore per-sender limit in the pool. + /// + /// If you return `true` for given transaction it's going to be accepted even though + /// the per-sender limit is exceeded. + fn should_ignore_sender_limit(&self, _new: &T) -> bool { false } } /// A score with a reference to the transaction. diff --git a/transaction-pool/src/tests/helpers.rs b/transaction-pool/src/tests/helpers.rs index 76a81eb9a00..9918db91b43 100644 --- a/transaction-pool/src/tests/helpers.rs +++ b/transaction-pool/src/tests/helpers.rs @@ -77,6 +77,10 @@ impl Scoring for DummyScoring { scoring::Choice::RejectNew } } + + fn should_ignore_sender_limit(&self, _new: &Transaction) -> bool { + self.always_insert + } } #[derive(Default)] diff --git a/transaction-pool/src/tests/mod.rs b/transaction-pool/src/tests/mod.rs index 0029d0622f8..85260133e3e 100644 --- a/transaction-pool/src/tests/mod.rs +++ b/transaction-pool/src/tests/mod.rs @@ -591,6 +591,33 @@ fn should_not_import_even_if_limit_is_reached_and_should_replace_returns_false() }); } +#[test] +fn should_import_even_if_sender_limit_is_reached() { + // given + let b = TransactionBuilder::default(); + let mut txq = TestPool::with_scoring(DummyScoring::always_insert(), Options { + max_count: 1, + max_per_sender: 1, + ..Default::default() + }); + txq.import(b.tx().nonce(0).gas_price(5).new()).unwrap(); + assert_eq!(txq.light_status(), LightStatus { + transaction_count: 1, + senders: 1, + mem_usage: 0, + }); + + // when + txq.import(b.tx().nonce(1).gas_price(5).new()).unwrap(); + + // then + assert_eq!(txq.light_status(), LightStatus { + transaction_count: 2, + senders: 1, + mem_usage: 0, + }); +} + mod listener { use std::cell::RefCell; use std::rc::Rc; diff --git a/transaction-pool/src/transactions.rs b/transaction-pool/src/transactions.rs index edc26b69f4e..96fe2e91bc9 100644 --- a/transaction-pool/src/transactions.rs +++ b/transaction-pool/src/transactions.rs @@ -95,7 +95,7 @@ impl> Transactions { fn push_cheapest_transaction(&mut self, tx: Transaction, scoring: &S, max_count: usize) -> AddResult, S::Score> { let index = self.transactions.len(); - if index == max_count { + if index == max_count && !scoring.should_ignore_sender_limit(&tx) { let min_score = self.scores[index - 1].clone(); AddResult::TooCheapToEnter(tx, min_score) } else { diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml index bceb61c09c4..dbaa93e66ab 100644 --- a/util/version/Cargo.toml +++ b/util/version/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "parity-version" # NOTE: this value is used for Parity version string (via env CARGO_PKG_VERSION) -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] build = "build.rs"