From 2856305977d665b2af42aa06dcc17f15e77335d7 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 20 Dec 2017 12:36:04 +0100 Subject: [PATCH 01/14] Fix broken flex modal layouts (#7343) --- js-old/src/ui/AccountCard/accountCard.css | 1 - js-old/src/ui/Form/AddressSelect/addressSelect.css | 10 +--------- js-old/src/ui/Form/AddressSelect/addressSelect.js | 2 +- js-old/src/ui/Portal/portal.css | 7 +++---- js-old/src/ui/SelectionList/selectionList.css | 2 -- 5 files changed, 5 insertions(+), 17 deletions(-) diff --git a/js-old/src/ui/AccountCard/accountCard.css b/js-old/src/ui/AccountCard/accountCard.css index e6cafe656..d260b78b7 100644 --- a/js-old/src/ui/AccountCard/accountCard.css +++ b/js-old/src/ui/AccountCard/accountCard.css @@ -20,7 +20,6 @@ background-color: rgba(0, 0, 0, 0.8); display: flex; flex-direction: row; - height: 100%; overflow: hidden; transition: transform ease-out 0.1s; transform: scale(1); diff --git a/js-old/src/ui/Form/AddressSelect/addressSelect.css b/js-old/src/ui/Form/AddressSelect/addressSelect.css index 5b7ced748..46c902c21 100644 --- a/js-old/src/ui/Form/AddressSelect/addressSelect.css +++ b/js-old/src/ui/Form/AddressSelect/addressSelect.css @@ -105,9 +105,7 @@ } .inputContainer { - display: flex; - flex-direction: column; - flex: 1; + justify-content: flex-start; .input { font-size: 1.5em; @@ -134,8 +132,6 @@ } .category { - display: flex; - flex-direction: column; margin: 0 0.5em; max-width: 35em; @@ -149,12 +145,8 @@ } .cards { - flex: 1; overflow: auto; - display: flex; - flex-direction: column; - margin: 1em 0; } diff --git a/js-old/src/ui/Form/AddressSelect/addressSelect.js b/js-old/src/ui/Form/AddressSelect/addressSelect.js index daa34d988..f02320a99 100644 --- a/js-old/src/ui/Form/AddressSelect/addressSelect.js +++ b/js-old/src/ui/Form/AddressSelect/addressSelect.js @@ -335,7 +335,7 @@ class AddressSelect extends Component { content = (
-
{ cards }
+ { cards }
); } diff --git a/js-old/src/ui/Portal/portal.css b/js-old/src/ui/Portal/portal.css index 85e8be4f1..96226f363 100644 --- a/js-old/src/ui/Portal/portal.css +++ b/js-old/src/ui/Portal/portal.css @@ -82,10 +82,9 @@ $popoverZ: 3600; /* but may well be) will scretch to non-visible areas. */ &.small { - margin: 1.5em auto; - max-width: 768px; - position: relative; - width: 75%; + left: 50%; + margin: 1.5em -384px; + width: 768px; } } diff --git a/js-old/src/ui/SelectionList/selectionList.css b/js-old/src/ui/SelectionList/selectionList.css index b6e6b05f9..00c658a13 100644 --- a/js-old/src/ui/SelectionList/selectionList.css +++ b/js-old/src/ui/SelectionList/selectionList.css @@ -19,7 +19,6 @@ cursor: pointer; display: flex; flex: 1; - height: 100%; position: relative; width: 100%; @@ -29,7 +28,6 @@ } .content { - height: 100%; width: 100%; &:hover { From 2f9532fe4b63efe2e1486ab2ba40cb11969294ff Mon Sep 17 00:00:00 2001 From: GitLab Build Bot Date: Wed, 20 Dec 2017 11:47:16 +0000 Subject: [PATCH 02/14] [ci skip] js-precompiled 20171220-114610 --- Cargo.lock | 2 +- js/package-lock.json | 2 +- js/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e843f44b2..f0f4bf88d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2246,7 +2246,7 @@ dependencies = [ [[package]] name = "parity-ui-old-precompiled" version = "1.9.0" -source = "git+https://github.com/js-dist-paritytech/parity-master-1-9-v1.git#95f866ff500abcf7cec527378f099cfc81e18093" +source = "git+https://github.com/js-dist-paritytech/parity-master-1-9-v1.git#d95164e94df10cb2bbcaa5dad36d6b61b760c3e1" dependencies = [ "parity-dapps-glue 1.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/js/package-lock.json b/js/package-lock.json index 7c253cc30..6a6a2c32c 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "Parity", - "version": "1.9.39", + "version": "1.9.40", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/js/package.json b/js/package.json index 87ce1e86d..b75bb67c8 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "Parity", - "version": "1.9.39", + "version": "1.9.40", "main": "src/index.parity.js", "jsnext:main": "src/index.parity.js", "author": "Parity Team ", From ab2caee0a3e2cd6500801b2a05f02a3ce70edde0 Mon Sep 17 00:00:00 2001 From: Yurii Rashkovskii Date: Wed, 20 Dec 2017 22:41:52 +0700 Subject: [PATCH 03/14] Problem: Cargo.toml file contains [project] key (#7346) This key is not recognized by some software (like carnix). It is also not documented in http://doc.crates.io/manifest.html Solution: rename this key to [package] --- util/bloom/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/bloom/Cargo.toml b/util/bloom/Cargo.toml index 99464879f..8c366a852 100644 --- a/util/bloom/Cargo.toml +++ b/util/bloom/Cargo.toml @@ -1,4 +1,4 @@ -[project] +[package] name = "ethcore-bloom-journal" version = "0.1.0" authors = ["Parity Technologies "] From 00883e477a98870fd9b07a1214ee973894d48a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 21 Dec 2017 11:18:04 +0100 Subject: [PATCH 04/14] Get rid of clippy remainings. --- Cargo.lock | 69 ------------------------ Cargo.toml | 2 - dapps/Cargo.toml | 4 -- dapps/js-glue/Cargo.toml | 3 -- dapps/src/lib.rs | 2 - ethcore/Cargo.toml | 2 - ethcore/evm/src/interpreter/gasometer.rs | 2 - ethcore/evm/src/interpreter/mod.rs | 2 - ethcore/src/basic_types.rs | 1 - ethcore/src/block.rs | 5 -- ethcore/src/blockchain/blockchain.rs | 4 -- ethcore/src/ethereum/ethash.rs | 1 - ethcore/src/externalities.rs | 2 - ethcore/src/lib.rs | 17 ------ ethcore/src/miner/miner.rs | 4 -- ethcore/src/miner/mod.rs | 2 - ethcore/src/miner/transaction_queue.rs | 2 - ethcore/src/service.rs | 1 - ethcore/src/snapshot/tests/helpers.rs | 1 - ethcore/src/state/mod.rs | 3 -- ethcore/src/state/substate.rs | 1 - ethcore/src/state_db.rs | 1 - ethcore/src/trace/db.rs | 1 - ethcore/src/verification/queue/mod.rs | 2 - ethcore/src/verification/verification.rs | 1 - ethcore/vm/src/ext.rs | 1 - ethcrypto/src/lib.rs | 2 - json/Cargo.toml | 1 - parity/informant.rs | 1 - parity/main.rs | 4 -- parity/upgrade.rs | 1 - rpc/Cargo.toml | 5 -- rpc/src/authcodes.rs | 2 - rpc/src/lib.rs | 2 - sync/Cargo.toml | 5 -- sync/src/chain.rs | 7 --- sync/src/lib.rs | 6 --- util/Cargo.toml | 2 - util/bigint/src/hash.rs | 2 - util/journaldb/src/archivedb.rs | 2 - util/journaldb/src/earlymergedb.rs | 3 -- util/journaldb/src/overlaydb.rs | 1 - util/journaldb/src/overlayrecentdb.rs | 2 - util/journaldb/src/refcounteddb.rs | 2 - util/network/Cargo.toml | 2 - util/network/src/discovery.rs | 1 - util/network/src/host.rs | 3 -- util/network/src/ip_utils.rs | 1 - util/patricia_trie/src/lib.rs | 1 - util/patricia_trie/src/triedb.rs | 1 - util/src/lib.rs | 17 ------ 51 files changed, 212 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0f4bf88d..e1104596a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -244,28 +244,6 @@ dependencies = [ "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "clippy" -version = "0.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "clippy_lints 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "clippy_lints" -version = "0.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "coco" version = "0.1.1" @@ -480,7 +458,6 @@ dependencies = [ "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bn 0.4.4 (git+https://github.com/paritytech/bn)", "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "common-types 0.1.0", "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.9.0", @@ -654,7 +631,6 @@ version = "1.9.0" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", @@ -739,7 +715,6 @@ dependencies = [ name = "ethcore-util" version = "1.9.0" dependencies = [ - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", @@ -783,7 +758,6 @@ dependencies = [ name = "ethjson" version = "0.1.0" dependencies = [ - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -865,7 +839,6 @@ dependencies = [ name = "ethsync" version = "1.9.0" dependencies = [ - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.9.0", "ethcore-bigint 0.2.1", @@ -1755,11 +1728,6 @@ dependencies = [ "odds 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nom" -version = "1.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "ntp" version = "0.3.1" @@ -1928,7 +1896,6 @@ dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_dirs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 1.1.1 (git+https://github.com/paritytech/rust-ctrlc.git)", "daemonize 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1996,7 +1963,6 @@ name = "parity-dapps" version = "1.9.0" dependencies = [ "base32 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", @@ -2032,7 +1998,6 @@ name = "parity-dapps-glue" version = "1.9.1" dependencies = [ "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", "quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2130,7 +2095,6 @@ version = "1.9.0" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "cid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.9.0", "ethcore 1.9.0", "ethcore-bigint 0.2.1", @@ -2558,11 +2522,6 @@ name = "quick-error" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "quine-mc_cluskey" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "quote" version = "0.3.15" @@ -2623,11 +2582,6 @@ dependencies = [ "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "regex-syntax" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "regex-syntax" version = "0.4.1" @@ -2856,14 +2810,6 @@ name = "semver" version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "semver" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "semver" version = "0.6.0" @@ -3276,14 +3222,6 @@ dependencies = [ "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "toml" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "toml" version = "0.4.5" @@ -3615,8 +3553,6 @@ dependencies = [ "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum cid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "34aa7da06f10541fbca6850719cdaa8fa03060a5d2fb33840f149cf8133a00c7" "checksum clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3451e409013178663435d6f15fdb212f14ee4424a3d74f979d081d0a66b6f1f2" -"checksum clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "5b4fabf979ddf6419a313c1c0ada4a5b95cfd2049c56e8418d622d27b4b6ff32" -"checksum clippy_lints 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "ce96ec05bfe018a0d5d43da115e54850ea2217981ff0f2e462780ab9d594651a" "checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd" "checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" "checksum cookie 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d53b80dde876f47f03cda35303e368a79b91c70b0d65ecba5fd5280944a08591" @@ -3710,7 +3646,6 @@ dependencies = [ "checksum native-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04b781c9134a954c84f0594b9ab3f5606abc516030388e8511887ef4c204a1e5" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum nodrop 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "52cd74cd09beba596430cc6e3091b74007169a56246e1262f0ba451ea95117b2" -"checksum nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce" "checksum ntp 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "143149743832c6543b60a8ef2a26cd9122dfecec2b767158e852a7beecf6d7a0" "checksum num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "a311b77ebdc5dd4cf6449d81e4135d9f0e3b153839ac90e648a8ef538f923525" "checksum num-bigint 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "8fd0f8dbb4c0960998958a796281d88c16fbe68d87b1baa6f31e2979e81fd0bd" @@ -3756,7 +3691,6 @@ dependencies = [ "checksum quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9e25fa23c044c1803f43ca59c98dac608976dd04ce799411edd58ece776d4" "checksum quasi_macros 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29cec87bc2816766d7e4168302d505dd06b0a825aed41b00633d296e922e02dd" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" -"checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" "checksum rayon 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a77c51c07654ddd93f6cb543c7a849863b03abc7e82591afda6dc8ad4ac3ac4a" @@ -3764,7 +3698,6 @@ dependencies = [ "checksum rayon-core 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7febc28567082c345f10cddc3612c6ea020fc3297a1977d472cf9fdb73e6e493" "checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" -"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" "checksum reqwest 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5866613d84e2a39c0479a960bf2d0eff1fbfc934f02cd42b5c08c1e1efc5b1fd" "checksum ring 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "24293de46bac74c9b9c05b40ff8496bbc8b9ae242a9b89f754e1154a43bc7c4c" @@ -3787,7 +3720,6 @@ dependencies = [ "checksum security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "dfa44ee9c54ce5eecc9de7d5acbad112ee58755239381f687e564004ba4a2332" "checksum security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "5421621e836278a0b139268f36eee0dc7e389b784dc3f79d8f11aabadf41bead" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" -"checksum semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2d5b7638a1f03815d94e88cb3b3c08e87f0db4d683ef499d1836aaf70a45623f" "checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "6a7046c9d4c6c522d10b2d098f9bebe2bef227e0e74044d8c1bfcf6b476af799" @@ -3835,7 +3767,6 @@ dependencies = [ "checksum tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6131e780037787ff1b3f8aad9da83bca02438b72277850dd6ad0d455e0e20efc" "checksum tokio-tls 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d88e411cac1c87e405e4090be004493c5d8072a370661033b1a64ea205ec2e13" "checksum tokio-uds 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6116c71be48f8f1656551fd16458247fdd6c03201d7893ad81189055fcde03e8" -"checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum transient-hashmap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "715254c8f0811be1a79ad3ea5e6fa3c8eddec2b03d7f5ba78cf093e56d79c24f" diff --git a/Cargo.toml b/Cargo.toml index 07573cdd7..31a0c1d28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,6 @@ kvdb-rocksdb = { path = "util/kvdb-rocksdb" } journaldb = { path = "util/journaldb" } parity-dapps = { path = "dapps", optional = true } -clippy = { version = "0.0.103", optional = true} ethcore-secretstore = { path = "secret_store", optional = true } [build-dependencies] @@ -94,7 +93,6 @@ ui-precompiled = [ ui-enabled = ["dapps"] dapps = ["parity-dapps"] jit = ["ethcore/jit"] -dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "parity-rpc/dev", "parity-dapps/dev"] json-tests = ["ethcore/json-tests"] test-heavy = ["ethcore/test-heavy"] evm-debug = ["ethcore/evm-debug"] diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index f3e02826d..f44bc2d92 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -38,14 +38,10 @@ parity-reactor = { path = "../util/reactor" } parity-ui = { path = "./ui" } keccak-hash = { path = "../util/hash" } -clippy = { version = "0.0.103", optional = true} - [dev-dependencies] env_logger = "0.4" ethcore-devtools = { path = "../devtools" } [features] -dev = ["clippy", "ethcore-util/dev"] - ui = ["parity-ui/no-precompiled-js"] ui-precompiled = ["parity-ui/use-precompiled-js"] diff --git a/dapps/js-glue/Cargo.toml b/dapps/js-glue/Cargo.toml index 4cad9cdab..efe92bbda 100644 --- a/dapps/js-glue/Cargo.toml +++ b/dapps/js-glue/Cargo.toml @@ -18,13 +18,10 @@ quasi = { version = "0.32", default-features = false } quasi_macros = { version = "0.32", optional = true } syntex = { version = "0.58", optional = true } syntex_syntax = { version = "0.58", optional = true } -clippy = { version = "0.0.103", optional = true } [features] -dev = ["clippy"] default = ["with-syntex"] nightly = ["quasi_macros"] -nightly-testing = ["clippy"] with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex", "syntex", "syntex_syntax"] use-precompiled-js = [] diff --git a/dapps/src/lib.rs b/dapps/src/lib.rs index 85087242b..0d9a33aa7 100644 --- a/dapps/src/lib.rs +++ b/dapps/src/lib.rs @@ -16,8 +16,6 @@ //! Ethcore Webapplications for Parity #![warn(missing_docs)] -#![cfg_attr(feature="nightly", feature(plugin))] -#![cfg_attr(feature="nightly", plugin(clippy))] extern crate base32; extern crate futures_cpupool; diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 8d7301438..27a8dccd7 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -11,7 +11,6 @@ ansi_term = "0.9" bloomchain = "0.1" bn = { git = "https://github.com/paritytech/bn" } byteorder = "1.0" -clippy = { version = "0.0.103", optional = true} common-types = { path = "types" } crossbeam = "0.2.9" ethash = { path = "../ethash" } @@ -83,6 +82,5 @@ evm-debug-tests = ["evm-debug"] slow-blocks = [] # Use SLOW_TX_DURATION="50" (compile time!) to track transactions over 50ms json-tests = [] test-heavy = [] -dev = ["clippy"] default = [] benches = [] diff --git a/ethcore/evm/src/interpreter/gasometer.rs b/ethcore/evm/src/interpreter/gasometer.rs index 082868b95..a7fe2a331 100644 --- a/ethcore/evm/src/interpreter/gasometer.rs +++ b/ethcore/evm/src/interpreter/gasometer.rs @@ -32,7 +32,6 @@ macro_rules! overflowing { }} } -#[cfg_attr(feature="dev", allow(enum_variant_names))] enum Request { Gas(Cost), GasMem(Cost, Cost), @@ -101,7 +100,6 @@ impl Gasometer { } } - #[cfg_attr(feature="dev", allow(cyclomatic_complexity))] /// Determine how much gas is used by the given instruction, given the machine's state. /// /// We guarantee that the final element of the returned tuple (`provided`) will be `Some` diff --git a/ethcore/evm/src/interpreter/mod.rs b/ethcore/evm/src/interpreter/mod.rs index 2042bbb1d..6ea218ecf 100644 --- a/ethcore/evm/src/interpreter/mod.rs +++ b/ethcore/evm/src/interpreter/mod.rs @@ -66,7 +66,6 @@ struct CodeReader<'a> { code: &'a [u8] } -#[cfg_attr(feature="dev", allow(len_without_is_empty))] impl<'a> CodeReader<'a> { /// Create new code reader - starting at position 0. @@ -287,7 +286,6 @@ impl Interpreter { } } - #[cfg_attr(feature="dev", allow(too_many_arguments))] fn exec_instruction( &mut self, gas: Cost, diff --git a/ethcore/src/basic_types.rs b/ethcore/src/basic_types.rs index 838834eea..e7f372352 100644 --- a/ethcore/src/basic_types.rs +++ b/ethcore/src/basic_types.rs @@ -22,7 +22,6 @@ pub type LogBloom = ::log_entry::LogBloom; /// Constant 2048-bit datum for 0. Often used as a default. pub static ZERO_LOGBLOOM: LogBloom = ::bigint::hash::H2048([0x00; 256]); -#[cfg_attr(feature="dev", allow(enum_variant_names))] /// Semantic boolean for when a seal/signature is included. pub enum Seal { /// The seal/signature is included. diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index ddf72be2c..2925f8d44 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -301,7 +301,6 @@ pub struct SealedBlock { } impl<'x> OpenBlock<'x> { - #[cfg_attr(feature="dev", allow(too_many_arguments))] /// Create a new `OpenBlock` ready for transaction pushing. pub fn new( engine: &'x EthEngine, @@ -614,7 +613,6 @@ impl IsBlock for SealedBlock { } /// Enact the block given by block header, transactions and uncles -#[cfg_attr(feature="dev", allow(too_many_arguments))] pub fn enact( header: &Header, transactions: &[SignedTransaction], @@ -688,7 +686,6 @@ fn push_transactions(block: &mut OpenBlock, transactions: &[SignedTransaction]) // TODO [ToDr] Pass `PreverifiedBlock` by move, this will avoid unecessary allocation /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header -#[cfg_attr(feature="dev", allow(too_many_arguments))] pub fn enact_verified( block: &PreverifiedBlock, engine: &EthEngine, @@ -731,7 +728,6 @@ mod tests { use transaction::SignedTransaction; /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header - #[cfg_attr(feature="dev", allow(too_many_arguments))] fn enact_bytes( block_bytes: &[u8], engine: &EthEngine, @@ -778,7 +774,6 @@ mod tests { } /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header. Seal the block aferwards - #[cfg_attr(feature="dev", allow(too_many_arguments))] fn enact_and_seal( block_bytes: &[u8], engine: &EthEngine, diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 8e71d5f42..cdd8f82c3 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -970,7 +970,6 @@ impl BlockChain { self.cache_man.lock().note_used(CacheId::BlockDetails(block_hash)); } - #[cfg_attr(feature="dev", allow(similar_names))] /// Inserts the block into backing cache database. /// Expects the block to be valid and already verified. /// If the block is already known, does nothing. @@ -1475,7 +1474,6 @@ impl BlockChain { #[cfg(test)] mod tests { - #![cfg_attr(feature="dev", allow(similar_names))] use std::sync::Arc; use rustc_hex::FromHex; use hash::keccak; @@ -1583,7 +1581,6 @@ mod tests { } #[test] - #[cfg_attr(feature="dev", allow(cyclomatic_complexity))] fn test_find_uncles() { let mut canon_chain = ChainGenerator::default(); let mut finalizer = BlockFinalizer::default(); @@ -1793,7 +1790,6 @@ mod tests { } #[test] - #[cfg_attr(feature="dev", allow(cyclomatic_complexity))] fn test_small_fork() { let mut canon_chain = ChainGenerator::default(); let mut finalizer = BlockFinalizer::default(); diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index 55f0d58de..70fdcbb82 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -336,7 +336,6 @@ impl Engine for Arc { } } -#[cfg_attr(feature="dev", allow(wrong_self_convention))] impl Ethash { fn calculate_difficulty(&self, header: &Header, parent: &Header) -> U256 { const EXP_DIFF_PERIOD: u64 = 100_000; diff --git a/ethcore/src/externalities.rs b/ethcore/src/externalities.rs index ff7805299..a88eae85f 100644 --- a/ethcore/src/externalities.rs +++ b/ethcore/src/externalities.rs @@ -85,7 +85,6 @@ impl<'a, T: 'a, V: 'a, B: 'a> Externalities<'a, T, V, B> where T: Tracer, V: VMTracer, B: StateBackend { /// Basic `Externalities` constructor. - #[cfg_attr(feature="dev", allow(too_many_arguments))] pub fn new(state: &'a mut State, env_info: &'a EnvInfo, machine: &'a Machine, @@ -302,7 +301,6 @@ impl<'a, T: 'a, V: 'a, B: 'a> Ext for Externalities<'a, T, V, B> Ok(self.state.code_size(address)?.unwrap_or(0)) } - #[cfg_attr(feature="dev", allow(match_ref_pats))] fn ret(mut self, gas: &U256, data: &ReturnData, apply_state: bool) -> vm::Result where Self: Sized { let handle_copy = |to: &mut Option<&mut Bytes>| { diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index b969a39dd..fdbd35e95 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -16,23 +16,6 @@ #![warn(missing_docs)] #![cfg_attr(feature="benches", feature(test))] -#![cfg_attr(feature="dev", feature(plugin))] -#![cfg_attr(feature="dev", plugin(clippy))] - -// Clippy settings -// Most of the time much more readable -#![cfg_attr(feature="dev", allow(needless_range_loop))] -// Shorter than if-else -#![cfg_attr(feature="dev", allow(match_bool))] -// Keeps consistency (all lines with `.clone()`). -#![cfg_attr(feature="dev", allow(clone_on_copy))] -// Complains on Box when implementing From> -#![cfg_attr(feature="dev", allow(boxed_local))] -// Complains about nested modules with same name as parent -#![cfg_attr(feature="dev", allow(module_inception))] -// TODO [todr] a lot of warnings to be fixed -#![cfg_attr(feature="dev", allow(assign_op_pattern))] - //! Ethcore library //! diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 4f1d5b687..df82a926c 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -366,7 +366,6 @@ impl Miner { ) } - #[cfg_attr(feature="dev", allow(match_same_arms))] /// Prepares new block for sealing including top transactions from queue. fn prepare_block(&self, chain: &MiningBlockChainClient) -> (ClosedBlock, Option) { let _timer = PerfTimer::new("prepare_block"); @@ -708,8 +707,6 @@ impl Miner { /// Are we allowed to do a non-mandatory reseal? fn tx_reseal_allowed(&self) -> bool { Instant::now() > *self.next_allowed_reseal.lock() } - #[cfg_attr(feature="dev", allow(wrong_self_convention))] - #[cfg_attr(feature="dev", allow(redundant_closure))] fn from_pending_block(&self, latest_block_number: BlockNumber, from_chain: F, map_block: G) -> H where F: Fn() -> H, G: FnOnce(&ClosedBlock) -> H { let sealing_work = self.sealing_work.lock(); @@ -869,7 +866,6 @@ impl MinerService for Miner { results } - #[cfg_attr(feature="dev", allow(collapsible_if))] fn import_own_transaction( &self, chain: &MiningBlockChainClient, diff --git a/ethcore/src/miner/mod.rs b/ethcore/src/miner/mod.rs index 6e1504c21..e82591cf1 100644 --- a/ethcore/src/miner/mod.rs +++ b/ethcore/src/miner/mod.rs @@ -15,8 +15,6 @@ // along with Parity. If not, see . #![warn(missing_docs)] -#![cfg_attr(all(nightly, feature="dev"), feature(plugin))] -#![cfg_attr(all(nightly, feature="dev"), plugin(clippy))] //! Miner module //! Keeps track of transactions and mined block. diff --git a/ethcore/src/miner/transaction_queue.rs b/ethcore/src/miner/transaction_queue.rs index 9cb835b28..f553e187e 100644 --- a/ethcore/src/miner/transaction_queue.rs +++ b/ethcore/src/miner/transaction_queue.rs @@ -136,7 +136,6 @@ impl PartialOrd for TransactionOrigin { } impl Ord for TransactionOrigin { - #[cfg_attr(feature="dev", allow(match_same_arms))] fn cmp(&self, other: &TransactionOrigin) -> Ordering { if *other == *self { return Ordering::Equal; @@ -516,7 +515,6 @@ pub struct AccountDetails { const GAS_PRICE_BUMP_SHIFT: usize = 3; // 2 = 25%, 3 = 12.5%, 4 = 6.25% /// Describes the strategy used to prioritize transactions in the queue. -#[cfg_attr(feature="dev", allow(enum_variant_names))] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum PrioritizationStrategy { /// Use only gas price. Disregards the actual computation cost of the transaction. diff --git a/ethcore/src/service.rs b/ethcore/src/service.rs index 078f02d46..a4b5b22f6 100644 --- a/ethcore/src/service.rs +++ b/ethcore/src/service.rs @@ -186,7 +186,6 @@ impl IoHandler for ClientIoHandler { } } - #[cfg_attr(feature="dev", allow(single_match))] fn message(&self, _io: &IoContext, net_message: &ClientIoMessage) { use std::thread; diff --git a/ethcore/src/snapshot/tests/helpers.rs b/ethcore/src/snapshot/tests/helpers.rs index a6f0cbb05..ee1238252 100644 --- a/ethcore/src/snapshot/tests/helpers.rs +++ b/ethcore/src/snapshot/tests/helpers.rs @@ -57,7 +57,6 @@ impl StateProducer { } } - #[cfg_attr(feature="dev", allow(let_and_return))] /// Tick the state producer. This alters the state, writing new data into /// the database. pub fn tick(&mut self, rng: &mut R, db: &mut HashDB) { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index a7a5a303b..532094a4f 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -604,7 +604,6 @@ impl State { } /// Add `incr` to the balance of account `a`. - #[cfg_attr(feature="dev", allow(single_match))] pub fn add_balance(&mut self, a: &Address, incr: &U256, cleanup_mode: CleanupMode) -> trie::Result<()> { trace!(target: "state", "add_balance({}, {}): {}", a, incr, self.balance(a)?); let is_value_transfer = !incr.is_zero(); @@ -744,8 +743,6 @@ impl State { } /// Commits our cached account changes into the trie. - #[cfg_attr(feature="dev", allow(match_ref_pats))] - #[cfg_attr(feature="dev", allow(needless_borrow))] pub fn commit(&mut self) -> Result<(), Error> { // first, commit the sub trees. let mut accounts = self.cache.borrow_mut(); diff --git a/ethcore/src/state/substate.rs b/ethcore/src/state/substate.rs index 8d90c64d1..5d385089f 100644 --- a/ethcore/src/state/substate.rs +++ b/ethcore/src/state/substate.rs @@ -58,7 +58,6 @@ impl Substate { } /// Get the cleanup mode object from this. - #[cfg_attr(feature="dev", allow(wrong_self_convention))] pub fn to_cleanup_mode(&mut self, schedule: &Schedule) -> CleanupMode { match (schedule.kill_dust != CleanDustMode::Off, schedule.no_empty, schedule.kill_empty) { (false, false, _) => CleanupMode::ForceCreate, diff --git a/ethcore/src/state_db.rs b/ethcore/src/state_db.rs index 953b7b388..1b8d4c406 100644 --- a/ethcore/src/state_db.rs +++ b/ethcore/src/state_db.rs @@ -427,7 +427,6 @@ impl state::Backend for StateDB { cache.accounts.get_mut(addr).map(|a| a.as_ref().map(|a| a.clone_basic())) } - #[cfg_attr(feature="dev", allow(map_clone))] fn get_cached_code(&self, hash: &H256) -> Option>> { let mut cache = self.code_cache.lock(); diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 9d7136cb1..e90eedc4b 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -34,7 +34,6 @@ use cache_manager::CacheManager; const TRACE_DB_VER: &'static [u8] = b"1.0"; #[derive(Debug, Copy, Clone)] -#[cfg_attr(feature="dev", allow(enum_variant_names))] enum TraceDBIndex { /// Block traces index. BlockTraces = 0, diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index bf7c9ef5c..5cd0f35f7 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -164,7 +164,6 @@ struct QueueSignal { } impl QueueSignal { - #[cfg_attr(feature="dev", allow(bool_comparison))] fn set_sync(&self) { // Do not signal when we are about to close if self.deleting.load(AtomicOrdering::Relaxed) { @@ -179,7 +178,6 @@ impl QueueSignal { } } - #[cfg_attr(feature="dev", allow(bool_comparison))] fn set_async(&self) { // Do not signal when we are about to close if self.deleting.load(AtomicOrdering::Relaxed) { diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index a418236ed..18b86c090 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -498,7 +498,6 @@ mod tests { } #[test] - #[cfg_attr(feature="dev", allow(similar_names))] fn test_verify_block() { use rlp::RlpStream; diff --git a/ethcore/vm/src/ext.rs b/ethcore/vm/src/ext.rs index 3f5004586..daf00e074 100644 --- a/ethcore/vm/src/ext.rs +++ b/ethcore/vm/src/ext.rs @@ -96,7 +96,6 @@ pub trait Ext { /// Returns Err, if we run out of gas. /// Otherwise returns call_result which contains gas left /// and true if subcall was successfull. - #[cfg_attr(feature="dev", allow(too_many_arguments))] fn call(&mut self, gas: &U256, sender_address: &Address, diff --git a/ethcrypto/src/lib.rs b/ethcrypto/src/lib.rs index 3d34a7975..15b8640ee 100644 --- a/ethcrypto/src/lib.rs +++ b/ethcrypto/src/lib.rs @@ -174,7 +174,6 @@ pub mod aes { } /// ECDH functions -#[cfg_attr(feature="dev", allow(similar_names))] pub mod ecdh { use secp256k1::{ecdh, key, Error as SecpError}; use ethkey::{Secret, Public, SECP256K1}; @@ -199,7 +198,6 @@ pub mod ecdh { } /// ECIES function -#[cfg_attr(feature="dev", allow(similar_names))] pub mod ecies { use rcrypto::digest::Digest; use rcrypto::sha2::Sha256; diff --git a/json/Cargo.toml b/json/Cargo.toml index dbc365a1d..5d468a14f 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -9,5 +9,4 @@ rustc-hex = "1.0" serde = "1.0" serde_json = "1.0" serde_derive = "1.0" -clippy = { version = "0.0.103", optional = true} diff --git a/parity/informant.rs b/parity/informant.rs index 56bb3ad4d..cd2205382 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -252,7 +252,6 @@ impl Informant { self.in_shutdown.store(true, ::std::sync::atomic::Ordering::SeqCst); } - #[cfg_attr(feature="dev", allow(match_bool))] pub fn tick(&self) { let elapsed = self.last_tick.read().elapsed(); if elapsed < Duration::from_secs(5) { diff --git a/parity/main.rs b/parity/main.rs index eae471dce..9ed01b6f7 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -17,10 +17,6 @@ //! Ethcore client application. #![warn(missing_docs)] -#![cfg_attr(feature="dev", feature(plugin))] -#![cfg_attr(feature="dev", plugin(clippy))] -#![cfg_attr(feature="dev", allow(useless_format))] -#![cfg_attr(feature="dev", allow(match_bool))] extern crate ansi_term; extern crate app_dirs; diff --git a/parity/upgrade.rs b/parity/upgrade.rs index 99d2abdcb..49f18d571 100644 --- a/parity/upgrade.rs +++ b/parity/upgrade.rs @@ -27,7 +27,6 @@ use dir::{DatabaseDirectories, default_data_path}; use helpers::replace_home; use journaldb::Algorithm; -#[cfg_attr(feature="dev", allow(enum_variant_names))] #[derive(Debug)] pub enum Error { CannotCreateConfigPath, diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 9ed55bc63..6fba076e8 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -60,13 +60,8 @@ vm = { path = "../ethcore/vm" } keccak-hash = { path = "../util/hash" } hardware-wallet = { path = "../hw" } -clippy = { version = "0.0.103", optional = true} - [dev-dependencies] pretty_assertions = "0.1" macros = { path = "../util/macros" } ethcore-network = { path = "../util/network" } kvdb-memorydb = { path = "../util/kvdb-memorydb" } - -[features] -dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev"] diff --git a/rpc/src/authcodes.rs b/rpc/src/authcodes.rs index f1b2a391d..b0bb02fdf 100644 --- a/rpc/src/authcodes.rs +++ b/rpc/src/authcodes.rs @@ -83,7 +83,6 @@ pub struct AuthCodes { impl AuthCodes { /// Reads `AuthCodes` from file and creates new instance using `DefaultTimeProvider`. - #[cfg_attr(feature="dev", allow(single_char_pattern))] pub fn from_file(file: &Path) -> io::Result { let content = { if let Ok(mut file) = fs::File::open(file) { @@ -154,7 +153,6 @@ impl AuthCodes { /// Checks if given hash is correct authcode of `SignerUI` /// Updates this hash last used field in case it's valid. - #[cfg_attr(feature="dev", allow(wrong_self_convention))] pub fn is_valid(&mut self, hash: &H256, time: u64) -> bool { let now = self.now.now(); // check time diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 2e689feb8..d26a77c8e 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -17,8 +17,6 @@ //! Parity RPC. #![warn(missing_docs)] -#![cfg_attr(feature="dev", feature(plugin))] -#![cfg_attr(feature="dev", plugin(clippy))] #[macro_use] extern crate futures; diff --git a/sync/Cargo.toml b/sync/Cargo.toml index c2095c032..fea5fbf1e 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -20,7 +20,6 @@ keccak-hash = { path = "../util/hash" } triehash = { path = "../util/triehash" } kvdb = { path = "../util/kvdb" } macros = { path = "../util/macros" } -clippy = { version = "0.0.103", optional = true} log = "0.3" env_logger = "0.4" time = "0.1.34" @@ -34,7 +33,3 @@ ipnetwork = "0.12.6" [dev-dependencies] ethkey = { path = "../ethkey" } kvdb-memorydb = { path = "../util/kvdb-memorydb" } - -[features] -default = [] -dev = ["clippy", "ethcore/dev", "ethcore-util/dev"] diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 837fa4223..8cf21ef7b 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -469,7 +469,6 @@ impl ChainSync { self.peers.clear(); } - #[cfg_attr(feature="dev", allow(for_kv_map))] // Because it's not possible to get `values_mut()` /// Reset sync. Clear all downloaded data but keep the queue fn reset(&mut self, io: &mut SyncIo) { self.new_blocks.reset(); @@ -672,7 +671,6 @@ impl ChainSync { Ok(()) } - #[cfg_attr(feature="dev", allow(cyclomatic_complexity, needless_borrow))] /// Called by peer once it has new block headers during sync fn on_peer_block_headers(&mut self, io: &mut SyncIo, peer_id: PeerId, r: &UntrustedRlp) -> Result<(), PacketDecodeError> { let confirmed = match self.peers.get_mut(&peer_id) { @@ -883,7 +881,6 @@ impl ChainSync { } /// Called by peer once it has new block bodies - #[cfg_attr(feature="dev", allow(cyclomatic_complexity))] fn on_peer_new_block(&mut self, io: &mut SyncIo, peer_id: PeerId, r: &UntrustedRlp) -> Result<(), PacketDecodeError> { if !self.peers.get(&peer_id).map_or(false, |p| p.can_sync()) { trace!(target: "sync", "Ignoring new block from unconfirmed peer {}", peer_id); @@ -1333,7 +1330,6 @@ impl ChainSync { } /// Checks if there are blocks fully downloaded that can be imported into the blockchain and does the import. - #[cfg_attr(feature="dev", allow(block_in_if_condition_stmt))] fn collect_blocks(&mut self, io: &mut SyncIo, block_set: BlockSet) { match block_set { BlockSet::NewBlocks => { @@ -1353,7 +1349,6 @@ impl ChainSync { } /// Request headers from a peer by block hash - #[cfg_attr(feature="dev", allow(too_many_arguments))] fn request_headers_by_hash(&mut self, sync: &mut SyncIo, peer_id: PeerId, h: &H256, count: u64, skip: u64, reverse: bool, set: BlockSet) { trace!(target: "sync", "{} <- GetBlockHeaders: {} entries starting from {}, set = {:?}", peer_id, count, h, set); let mut rlp = RlpStream::new_list(4); @@ -1368,7 +1363,6 @@ impl ChainSync { } /// Request headers from a peer by block number - #[cfg_attr(feature="dev", allow(too_many_arguments))] fn request_fork_header_by_number(&mut self, sync: &mut SyncIo, peer_id: PeerId, n: BlockNumber) { trace!(target: "sync", "{} <- GetForkHeader: at {}", peer_id, n); let mut rlp = RlpStream::new_list(4); @@ -1783,7 +1777,6 @@ impl ChainSync { }) } - #[cfg_attr(feature="dev", allow(match_same_arms))] pub fn maintain_peers(&mut self, io: &mut SyncIo) { let tick = time::precise_time_ns(); let mut aborting = Vec::new(); diff --git a/sync/src/lib.rs b/sync/src/lib.rs index a88ab1032..2d020e43d 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -15,12 +15,6 @@ // along with Parity. If not, see . #![warn(missing_docs)] -#![cfg_attr(feature="dev", feature(plugin))] -#![cfg_attr(feature="dev", plugin(clippy))] -// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. -#![cfg_attr(feature="dev", allow(clone_on_copy))] -// In most cases it expresses function flow better -#![cfg_attr(feature="dev", allow(if_not_else))] //! Blockchain sync module //! Implements ethereum protocol version 63 as specified here: diff --git a/util/Cargo.toml b/util/Cargo.toml index ed65a8c47..964b19c8f 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -16,7 +16,6 @@ elastic-array = "0.9" rlp = { path = "rlp" } heapsize = "0.4" keccak-hash = { path = "hash" } -clippy = { version = "0.0.103", optional = true} libc = "0.2.7" target_info = "0.1" ethcore-bigint = { path = "bigint", features = ["heapsizeof"] } @@ -37,7 +36,6 @@ kvdb-memorydb = { path = "kvdb-memorydb" } [features] default = [] -dev = ["clippy"] final = [] [build-dependencies] diff --git a/util/bigint/src/hash.rs b/util/bigint/src/hash.rs index 212a1dd13..5581bbc20 100644 --- a/util/bigint/src/hash.rs +++ b/util/bigint/src/hash.rs @@ -179,7 +179,6 @@ macro_rules! impl_hash { } impl Copy for $from {} - #[cfg_attr(feature="dev", allow(expl_impl_clone_on_copy))] impl Clone for $from { fn clone(&self) -> $from { let mut ret = $from::new(); @@ -464,7 +463,6 @@ mod tests { } #[test] - #[cfg_attr(feature="dev", allow(eq_op))] fn hash() { let h = H64([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]); assert_eq!(H64::from_str("0123456789abcdef").unwrap(), h); diff --git a/util/journaldb/src/archivedb.rs b/util/journaldb/src/archivedb.rs index 5fa1277e4..bd5745900 100644 --- a/util/journaldb/src/archivedb.rs +++ b/util/journaldb/src/archivedb.rs @@ -196,8 +196,6 @@ impl JournalDB for ArchiveDB { #[cfg(test)] mod tests { - #![cfg_attr(feature="dev", allow(blacklisted_name))] - #![cfg_attr(feature="dev", allow(similar_names))] use keccak::keccak; use hashdb::{HashDB, DBValue}; diff --git a/util/journaldb/src/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs index 5ca023cb0..e9a1b80f9 100644 --- a/util/journaldb/src/earlymergedb.rs +++ b/util/journaldb/src/earlymergedb.rs @@ -447,7 +447,6 @@ impl JournalDB for EarlyMergeDB { } } - #[cfg_attr(feature="dev", allow(cyclomatic_complexity))] fn mark_canonical(&mut self, batch: &mut DBTransaction, end_era: u64, canon_id: &H256) -> Result { let mut refs = self.refs.as_ref().unwrap().write(); @@ -544,8 +543,6 @@ impl JournalDB for EarlyMergeDB { #[cfg(test)] mod tests { - #![cfg_attr(feature="dev", allow(blacklisted_name))] - #![cfg_attr(feature="dev", allow(similar_names))] use keccak::keccak; use hashdb::{HashDB, DBValue}; diff --git a/util/journaldb/src/overlaydb.rs b/util/journaldb/src/overlaydb.rs index 6844eb801..220076eaa 100644 --- a/util/journaldb/src/overlaydb.rs +++ b/util/journaldb/src/overlaydb.rs @@ -202,7 +202,6 @@ impl HashDB for OverlayDB { } #[test] -#[cfg_attr(feature="dev", allow(blacklisted_name))] fn overlaydb_revert() { let mut m = OverlayDB::new_temp(); let foo = m.insert(b"foo"); // insert foo. diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index d57e172d5..97fec7604 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -452,8 +452,6 @@ impl HashDB for OverlayRecentDB { #[cfg(test)] mod tests { - #![cfg_attr(feature="dev", allow(blacklisted_name))] - #![cfg_attr(feature="dev", allow(similar_names))] use keccak::keccak; use super::*; diff --git a/util/journaldb/src/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs index 6e114e476..e1d15383e 100644 --- a/util/journaldb/src/refcounteddb.rs +++ b/util/journaldb/src/refcounteddb.rs @@ -205,8 +205,6 @@ impl JournalDB for RefCountedDB { #[cfg(test)] mod tests { - #![cfg_attr(feature="dev", allow(blacklisted_name))] - #![cfg_attr(feature="dev", allow(similar_names))] use keccak::keccak; use hashdb::{HashDB, DBValue}; diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index c4718ba31..006bbc5ac 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -15,7 +15,6 @@ time = "0.1.34" tiny-keccak = "1.3" rust-crypto = "0.2.34" slab = "0.2" -clippy = { version = "0.0.103", optional = true} igd = "0.6" libc = "0.2.7" parking_lot = "0.4" @@ -41,4 +40,3 @@ tempdir = "0.3" [features] default = [] -dev = ["clippy"] diff --git a/util/network/src/discovery.rs b/util/network/src/discovery.rs index c2804f594..f75672bf5 100644 --- a/util/network/src/discovery.rs +++ b/util/network/src/discovery.rs @@ -281,7 +281,6 @@ impl Discovery { self.send_to(packet, address.clone()); } - #[cfg_attr(feature="dev", allow(map_clone))] fn nearest_node_entries(target: &NodeId, buckets: &[NodeBucket]) -> Vec { let mut found: BTreeMap> = BTreeMap::new(); let mut count = 0; diff --git a/util/network/src/host.rs b/util/network/src/host.rs index 9a5c4c0ca..5c770094d 100644 --- a/util/network/src/host.rs +++ b/util/network/src/host.rs @@ -705,7 +705,6 @@ impl Host { debug!(target: "network", "Connecting peers: {} sessions, {} pending, {} started", self.session_count(), self.handshake_count(), started); } - #[cfg_attr(feature="dev", allow(single_match))] fn connect_peer(&self, id: &NodeId, io: &IoContext) { if self.have_session(id) { trace!(target: "network", "Aborted connect. Node already connected."); @@ -744,7 +743,6 @@ impl Host { } } - #[cfg_attr(feature="dev", allow(block_in_if_condition_stmt))] fn create_connection(&self, socket: TcpStream, id: Option<&NodeId>, io: &IoContext) -> Result<(), Error> { let nonce = self.info.write().next_nonce(); let mut sessions = self.sessions.write(); @@ -805,7 +803,6 @@ impl Host { self.kill_connection(token, io, true); } - #[cfg_attr(feature="dev", allow(collapsible_if))] fn session_readable(&self, token: StreamToken, io: &IoContext) { let mut ready_data: Vec = Vec::new(); let mut packet_data: Vec<(ProtocolId, PacketId, Vec)> = Vec::new(); diff --git a/util/network/src/ip_utils.rs b/util/network/src/ip_utils.rs index d637dbee8..3767fbb15 100644 --- a/util/network/src/ip_utils.rs +++ b/util/network/src/ip_utils.rs @@ -365,7 +365,6 @@ fn can_map_external_address_or_fail() { #[test] fn ipv4_properties() { - #![cfg_attr(feature="dev", allow(too_many_arguments))] fn check(octets: &[u8; 4], unspec: bool, loopback: bool, private: bool, link_local: bool, global: bool, multicast: bool, broadcast: bool, documentation: bool) { diff --git a/util/patricia_trie/src/lib.rs b/util/patricia_trie/src/lib.rs index 07fd43bdf..83ab09073 100644 --- a/util/patricia_trie/src/lib.rs +++ b/util/patricia_trie/src/lib.rs @@ -268,7 +268,6 @@ impl<'db> Trie for TrieKinds<'db> { } } -#[cfg_attr(feature="dev", allow(wrong_self_convention))] impl TrieFactory { /// Creates new factory. pub fn new(spec: TrieSpec) -> Self { diff --git a/util/patricia_trie/src/triedb.rs b/util/patricia_trie/src/triedb.rs index 939957a65..39776d106 100644 --- a/util/patricia_trie/src/triedb.rs +++ b/util/patricia_trie/src/triedb.rs @@ -57,7 +57,6 @@ pub struct TrieDB<'db> { pub hash_count: usize, } -#[cfg_attr(feature="dev", allow(wrong_self_convention))] impl<'db> TrieDB<'db> { /// Create a new trie with the backing database `db` and `root` /// Returns an error if `root` does not exist diff --git a/util/src/lib.rs b/util/src/lib.rs index a81680c91..18a95e470 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -15,23 +15,6 @@ // along with Parity. If not, see . #![warn(missing_docs)] -#![cfg_attr(feature="dev", feature(plugin))] -#![cfg_attr(feature="dev", plugin(clippy))] - -// Clippy settings -// Most of the time much more readable -#![cfg_attr(feature="dev", allow(needless_range_loop))] -// Shorter than if-else -#![cfg_attr(feature="dev", allow(match_bool))] -// We use that to be more explicit about handled cases -#![cfg_attr(feature="dev", allow(match_same_arms))] -// Keeps consistency (all lines with `.clone()`). -#![cfg_attr(feature="dev", allow(clone_on_copy))] -// Some false positives when doing pattern matching. -#![cfg_attr(feature="dev", allow(needless_borrow))] -// TODO [todr] a lot of warnings to be fixed -#![cfg_attr(feature="dev", allow(assign_op_pattern))] - //! Ethcore-util library //! From 516725abe4ad5d1182fef42e66ad36b466c10f00 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Thu, 21 Dec 2017 16:50:58 +0300 Subject: [PATCH 05/14] ok_or -> ok_or_else --- ethcore/src/engines/validator_set/contract.rs | 2 +- ethcore/src/engines/validator_set/multi.rs | 2 +- ethcore/src/engines/validator_set/safe_contract.rs | 2 +- parity/secretstore.rs | 2 +- secret_store/src/acl_storage.rs | 2 +- .../key_server_cluster/admin_sessions/share_add_session.rs | 2 +- .../key_server_cluster/admin_sessions/share_move_session.rs | 6 +++--- secret_store/src/key_storage.rs | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ethcore/src/engines/validator_set/contract.rs b/ethcore/src/engines/validator_set/contract.rs index 54e86b98b..da35484c6 100644 --- a/ethcore/src/engines/validator_set/contract.rs +++ b/ethcore/src/engines/validator_set/contract.rs @@ -58,7 +58,7 @@ impl ValidatorContract { let client = self.client.read().clone(); Box::new(move |a, d| client.as_ref() .and_then(Weak::upgrade) - .ok_or("No client!".into()) + .ok_or_else(|| "No client!".into()) .and_then(|c| { match c.as_full_client() { Some(c) => c.transact_contract(a, d) diff --git a/ethcore/src/engines/validator_set/multi.rs b/ethcore/src/engines/validator_set/multi.rs index 3f53b0363..c46cd2276 100644 --- a/ethcore/src/engines/validator_set/multi.rs +++ b/ethcore/src/engines/validator_set/multi.rs @@ -138,7 +138,7 @@ impl ValidatorSet for Multi { } *self.block_number.write() = Box::new(move |id| client .upgrade() - .ok_or("No client!".into()) + .ok_or_else(|| "No client!".into()) .and_then(|c| c.block_number(id).ok_or("Unknown block".into()))); } } diff --git a/ethcore/src/engines/validator_set/safe_contract.rs b/ethcore/src/engines/validator_set/safe_contract.rs index 695f2a658..3fe9bda6d 100644 --- a/ethcore/src/engines/validator_set/safe_contract.rs +++ b/ethcore/src/engines/validator_set/safe_contract.rs @@ -311,7 +311,7 @@ impl ValidatorSet for ValidatorSafeContract { let client = self.client.read().clone(); Box::new(move |addr, data| client.as_ref() .and_then(Weak::upgrade) - .ok_or("No client!".into()) + .ok_or_else(|| "No client!".into()) .and_then(|c| { match c.as_full_client() { Some(c) => c.call_contract(id, addr, data), diff --git a/parity/secretstore.rs b/parity/secretstore.rs index 416c9d547..a3a55654f 100644 --- a/parity/secretstore.rs +++ b/parity/secretstore.rs @@ -121,7 +121,7 @@ mod server { // Attempt to sign in the engine signer. let password = deps.accounts_passwords.iter() .find(|p| deps.account_provider.sign(account.clone(), Some((*p).clone()), Default::default()).is_ok()) - .ok_or(format!("No valid password for the secret store node account {}", account))?; + .ok_or_else(|| format!("No valid password for the secret store node account {}", account))?; Arc::new(ethcore_secretstore::KeyStoreNodeKeyPair::new(deps.account_provider, account, password.clone()) .map_err(|e| format!("{}", e))?) }, diff --git a/secret_store/src/acl_storage.rs b/secret_store/src/acl_storage.rs index c06929e94..c8c46d5c0 100644 --- a/secret_store/src/acl_storage.rs +++ b/secret_store/src/acl_storage.rs @@ -111,7 +111,7 @@ impl CachedContract { let do_call = |a, d| future::done( self.client .upgrade() - .ok_or("Calling contract without client".into()) + .ok_or_else(|| "Calling contract without client".into()) .and_then(|c| c.call_contract(BlockId::Latest, a, d))); contract.check_permissions(do_call, address, document.clone()) .map_err(|err| Error::Internal(err)) diff --git a/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs b/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs index 040360d7d..433b49db6 100644 --- a/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs +++ b/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs @@ -258,7 +258,7 @@ impl SessionImpl where T: SessionTransport { let admin_public = self.core.admin_public.as_ref().cloned().ok_or(Error::ConsensusUnreachable)?; // key share version is required on ShareAdd master node - let key_share = self.core.key_share.as_ref().ok_or(Error::KeyStorage("key share is not found on master node".into()))?; + let key_share = self.core.key_share.as_ref().ok_or_else(|| Error::KeyStorage("key share is not found on master node".into()))?; let key_version = key_share.version(&version).map_err(|e| Error::KeyStorage(e.into()))?; // old nodes set is all non-isolated owners of version holders diff --git a/secret_store/src/key_server_cluster/admin_sessions/share_move_session.rs b/secret_store/src/key_server_cluster/admin_sessions/share_move_session.rs index d193e9efd..da75d095d 100644 --- a/secret_store/src/key_server_cluster/admin_sessions/share_move_session.rs +++ b/secret_store/src/key_server_cluster/admin_sessions/share_move_session.rs @@ -188,7 +188,7 @@ impl SessionImpl where T: SessionTransport { let is_consensus_pre_established = data.shares_to_move.is_some(); if !is_consensus_pre_established { let shares_to_move_reversed = shares_to_move_reversed.ok_or(Error::InvalidMessage)?; - let key_share = self.core.key_share.as_ref().ok_or(Error::KeyStorage("key share is not found on master node".into()))?; + let key_share = self.core.key_share.as_ref().ok_or_else(|| Error::KeyStorage("key share is not found on master node".into()))?; check_shares_to_move(&self.core.meta.self_node_id, &shares_to_move_reversed, Some(&key_share.id_numbers))?; let old_set_signature = old_set_signature.ok_or(Error::InvalidMessage)?; @@ -424,7 +424,7 @@ impl SessionImpl where T: SessionTransport { if !move_confirmations_to_receive.remove(sender) { return Err(Error::InvalidMessage); } - + if !move_confirmations_to_receive.is_empty() { return Ok(()); } @@ -818,7 +818,7 @@ mod tests { // check that session has completed on all nodes assert!(ml.nodes.values().all(|n| n.session.is_finished())); - + // check that secret is still the same as before adding the share check_secret_is_preserved(ml.original_key_pair.clone(), ml.nodes.iter() .filter(|&(k, _)| !shares_to_move.values().any(|v| v == k)) diff --git a/secret_store/src/key_storage.rs b/secret_store/src/key_storage.rs index fec58de2b..0997ea765 100644 --- a/secret_store/src/key_storage.rs +++ b/secret_store/src/key_storage.rs @@ -149,7 +149,7 @@ impl PersistentKeyStorage { pub fn new(config: &ServiceConfiguration) -> Result { let mut db_path = PathBuf::from(&config.data_path); db_path.push("db"); - let db_path = db_path.to_str().ok_or(Error::Database("Invalid secretstore path".to_owned()))?; + let db_path = db_path.to_str().ok_or_else(|| Error::Database("Invalid secretstore path".to_owned()))?; let db = Database::open_default(&db_path)?; let db = upgrade_db(db)?; From d5b81ead71a8c4b3eca5cc3dd18e575534cf73a6 Mon Sep 17 00:00:00 2001 From: Yurii Rashkovskii Date: Thu, 21 Dec 2017 20:59:09 +0700 Subject: [PATCH 06/14] Problem: AuRa's unsafeties around step duration (#7282) Firstly, `Step.duration_remaining` casts it to u32, unnecesarily limiting it to 2^32. While theoretically this is "good enough" (at 3 seconds steps it provides room for a little over 400 years), it is still a lossy way to calculate the remaining time until the next step. Secondly, step duration might be zero, triggering division by zero in `Step.calibrate` Solution: rework the code around the fact that duration is typically in single digits and never grows, hence, it can be represented by a much narrower range (u16) and this highlights the fact that multiplying u64 by u16 will only result in an overflow in even further future, at which point we should panic informatively (if anybody's still around) Similarly, panic when it is detected that incrementing the step counter wrapped around on the overflow of usize. As for the division by zero, prevent it by making zero an invalid value for step duration. This will make AuRa log the constraint mismatch and panic (after all, what purpose would zero step duration serve? it makes no sense within the definition of the protocol, as finality can only be achieved as per the specification if messages are received within the step duration, which would violate the speed of light and other physical laws in this case). --- ethcore/src/engines/authority_round/mod.rs | 110 ++++++++++++++++++--- json/src/spec/authority_round.rs | 2 +- 2 files changed, 97 insertions(+), 15 deletions(-) diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/src/engines/authority_round/mod.rs index 48638eda2..d9e1cb3b7 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -51,8 +51,12 @@ mod finality; /// `AuthorityRound` params. pub struct AuthorityRoundParams { - /// Time to wait before next block or authority switching. - pub step_duration: Duration, + /// Time to wait before next block or authority switching, + /// in seconds. + /// + /// Deliberately typed as u16 as too high of a value leads + /// to slow block issuance. + pub step_duration: u16, /// Starting step, pub start_step: Option, /// Valid validators. @@ -71,10 +75,17 @@ pub struct AuthorityRoundParams { pub maximum_uncle_count: usize, } +const U16_MAX: usize = ::std::u16::MAX as usize; + impl From for AuthorityRoundParams { fn from(p: ethjson::spec::AuthorityRoundParams) -> Self { + let mut step_duration_usize: usize = p.step_duration.into(); + if step_duration_usize > U16_MAX { + step_duration_usize = U16_MAX; + warn!(target: "engine", "step_duration is too high ({}), setting it to {}", step_duration_usize, U16_MAX); + } AuthorityRoundParams { - step_duration: Duration::from_secs(p.step_duration.into()), + step_duration: step_duration_usize as u16, validators: new_validator_set(p.validators), start_step: p.start_step.map(Into::into), validate_score_transition: p.validate_score_transition.map_or(0, Into::into), @@ -92,26 +103,47 @@ impl From for AuthorityRoundParams { struct Step { calibrate: bool, // whether calibration is enabled. inner: AtomicUsize, - duration: Duration, + duration: u16, } impl Step { fn load(&self) -> usize { self.inner.load(AtomicOrdering::SeqCst) } fn duration_remaining(&self) -> Duration { let now = unix_now(); - let step_end = self.duration * (self.load() as u32 + 1); - if step_end > now { - step_end - now - } else { - Duration::from_secs(0) + let expected_seconds = (self.load() as u64) + .checked_add(1) + .and_then(|ctr| ctr.checked_mul(self.duration as u64)); + match expected_seconds { + Some(secs) => { + let step_end = Duration::from_secs(secs); + if step_end > now { + step_end - now + } else { + Duration::from_secs(0) + } + }, + None => { + let ctr = self.load(); + error!(target: "engine", "Step counter is too high: {}, aborting", ctr); + panic!("step counter is too high: {}", ctr) + }, } + } fn increment(&self) { - self.inner.fetch_add(1, AtomicOrdering::SeqCst); + use std::usize; + // fetch_add won't panic on overflow but will rather wrap + // around, leading to zero as the step counter, which might + // lead to unexpected situations, so it's better to shut down. + if self.inner.fetch_add(1, AtomicOrdering::SeqCst) == usize::MAX { + error!(target: "engine", "Step counter is too high: {}, aborting", usize::MAX); + panic!("step counter is too high: {}", usize::MAX); + } + } fn calibrate(&self) { if self.calibrate { - let new_step = unix_now().as_secs() / self.duration.as_secs(); + let new_step = unix_now().as_secs() / (self.duration as u64); self.inner.store(new_step as usize, AtomicOrdering::SeqCst); } } @@ -359,8 +391,12 @@ impl AsMillis for Duration { impl AuthorityRound { /// Create a new instance of AuthorityRound engine. pub fn new(our_params: AuthorityRoundParams, machine: EthereumMachine) -> Result, Error> { + if our_params.step_duration == 0 { + error!(target: "engine", "Authority Round step duration can't be zero, aborting"); + panic!("authority_round: step duration can't be zero") + } let should_timeout = our_params.start_step.is_none(); - let initial_step = our_params.start_step.unwrap_or_else(|| (unix_now().as_secs() / our_params.step_duration.as_secs())) as usize; + let initial_step = our_params.start_step.unwrap_or_else(|| (unix_now().as_secs() / (our_params.step_duration as u64))) as usize; let engine = Arc::new( AuthorityRound { transition_service: IoService::<()>::start()?, @@ -1019,7 +1055,7 @@ mod tests { fn reports_skipped() { let last_benign = Arc::new(AtomicUsize::new(0)); let params = AuthorityRoundParams { - step_duration: Default::default(), + step_duration: 1, start_step: Some(1), validators: Box::new(TestSet::new(Default::default(), last_benign.clone())), validate_score_transition: 0, @@ -1059,7 +1095,7 @@ mod tests { fn test_uncles_transition() { let last_benign = Arc::new(AtomicUsize::new(0)); let params = AuthorityRoundParams { - step_duration: Default::default(), + step_duration: 1, start_step: Some(1), validators: Box::new(TestSet::new(Default::default(), last_benign.clone())), validate_score_transition: 0, @@ -1081,4 +1117,50 @@ mod tests { assert_eq!(aura.maximum_uncle_count(1), 0); assert_eq!(aura.maximum_uncle_count(100), 0); } + + #[test] + #[should_panic(expected="counter is too high")] + fn test_counter_increment_too_high() { + use super::Step; + let step = Step { + calibrate: false, + inner: AtomicUsize::new(::std::usize::MAX), + duration: 1, + }; + step.increment(); + } + + #[test] + #[should_panic(expected="counter is too high")] + fn test_counter_duration_remaining_too_high() { + use super::Step; + let step = Step { + calibrate: false, + inner: AtomicUsize::new(::std::usize::MAX), + duration: 1, + }; + step.duration_remaining(); + } + + #[test] + #[should_panic(expected="authority_round: step duration can't be zero")] + fn test_step_duration_zero() { + let last_benign = Arc::new(AtomicUsize::new(0)); + let params = AuthorityRoundParams { + step_duration: 0, + start_step: Some(1), + validators: Box::new(TestSet::new(Default::default(), last_benign.clone())), + validate_score_transition: 0, + validate_step_transition: 0, + immediate_transitions: true, + maximum_uncle_count_transition: 0, + maximum_uncle_count: 0, + block_reward: Default::default(), + }; + + let mut c_params = ::spec::CommonParams::default(); + c_params.gas_limit_bound_divisor = 5.into(); + let machine = ::machine::EthereumMachine::regular(c_params, Default::default()); + AuthorityRound::new(params, machine).unwrap(); + } } diff --git a/json/src/spec/authority_round.rs b/json/src/spec/authority_round.rs index f39db7344..57e354c72 100644 --- a/json/src/spec/authority_round.rs +++ b/json/src/spec/authority_round.rs @@ -22,7 +22,7 @@ use super::ValidatorSet; /// Authority params deserialization. #[derive(Debug, PartialEq, Deserialize)] pub struct AuthorityRoundParams { - /// Block duration. + /// Block duration, in seconds. #[serde(rename="stepDuration")] pub step_duration: Uint, /// Valid authorities From a5a7c1827aed3c4a8fa54e6d687dc5bde9aab20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 21 Dec 2017 15:37:10 +0100 Subject: [PATCH 07/14] Some more. --- parity/helpers.rs | 2 -- util/patricia_trie/src/triedbmut.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/parity/helpers.rs b/parity/helpers.rs index dc1644597..68bcce93d 100644 --- a/parity/helpers.rs +++ b/parity/helpers.rs @@ -217,7 +217,6 @@ pub fn default_network_config() -> ::ethsync::NetworkConfiguration { } } -#[cfg_attr(feature = "dev", allow(too_many_arguments))] pub fn to_client_config( cache_config: &CacheConfig, spec_name: String, @@ -453,7 +452,6 @@ but the first password is trimmed } #[test] - #[cfg_attr(feature = "dev", allow(float_cmp))] fn test_to_price() { assert_eq!(to_price("1").unwrap(), 1.0); assert_eq!(to_price("2.3").unwrap(), 2.3); diff --git a/util/patricia_trie/src/triedbmut.rs b/util/patricia_trie/src/triedbmut.rs index d0bef2181..497fe7284 100644 --- a/util/patricia_trie/src/triedbmut.rs +++ b/util/patricia_trie/src/triedbmut.rs @@ -436,7 +436,6 @@ impl<'a> TrieDBMut<'a> { } /// the insertion inspector. - #[cfg_attr(feature = "dev", allow(cyclomatic_complexity))] fn insert_inspector(&mut self, node: Node, partial: NibbleSlice, value: DBValue, old_val: &mut Option) -> super::Result { From 276496fb4b9dc700b9428825f90fa6c27cad4dc8 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Fri, 22 Dec 2017 04:33:17 +0100 Subject: [PATCH 08/14] Enable traces for DEV chain (#6949) (#7327) --- ethcore/src/client/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 6b5dbe59c..ade0844ec 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1855,7 +1855,7 @@ impl MiningBlockChainClient for Client { let mut open_block = OpenBlock::new( engine, self.factories.clone(), - false, // TODO: this will need to be parameterised once we want to do immediate mining insertion. + self.tracedb.read().tracing_enabled(), self.state_db.lock().boxed_clone_canon(&h), best_header, self.build_last_hashes(h.clone()), From 83447c201b0a338be48466115b086701a7af25c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 22 Dec 2017 04:33:49 +0100 Subject: [PATCH 09/14] Make accounts refresh time configurable. (#7345) * Configurable accounts refresh time. * Fix tests. --- ethstore/src/ethstore.rs | 67 +++++++++++++++++++++++++++++----------- parity/cli/mod.rs | 7 +++++ parity/configuration.rs | 1 + parity/params.rs | 2 ++ parity/run.rs | 10 ++++-- 5 files changed, 67 insertions(+), 20 deletions(-) diff --git a/ethstore/src/ethstore.rs b/ethstore/src/ethstore.rs index 1b8cf7ac2..07e7dd879 100755 --- a/ethstore/src/ethstore.rs +++ b/ethstore/src/ethstore.rs @@ -29,8 +29,6 @@ use presale::PresaleWallet; use json::{self, Uuid, OpaqueKeyFile}; use {import, Error, SimpleSecretStore, SecretStore, SecretVaultRef, StoreAccountRef, Derivation, OpaqueSecret}; -const REFRESH_TIME_SEC: u64 = 5; - /// Accounts store. pub struct EthStore { store: EthMultiStore, @@ -49,6 +47,16 @@ impl EthStore { }) } + /// Modify account refresh timeout - how often they are re-read from `KeyDirectory`. + /// + /// Setting this to low values (or 0) will cause new accounts to be picked up quickly, + /// although it may induce heavy disk reads and is not recommended if you manage many keys (say over 10k). + /// + /// By default refreshing is disabled, so only accounts created using this instance of `EthStore` are taken into account. + pub fn set_refresh_time(&self, time: Duration) { + self.store.set_refresh_time(time) + } + fn get(&self, account: &StoreAccountRef) -> Result { let mut accounts = self.store.get_accounts(account)?.into_iter(); accounts.next().ok_or(Error::InvalidAccount) @@ -254,6 +262,7 @@ pub struct EthMultiStore { struct Timestamp { dir_hash: Option, last_checked: Instant, + refresh_time: Duration, } impl EthMultiStore { @@ -272,16 +281,28 @@ impl EthMultiStore { timestamp: Mutex::new(Timestamp { dir_hash: None, last_checked: Instant::now(), + // by default we never refresh accounts + refresh_time: Duration::from_secs(u64::max_value()), }), }; store.reload_accounts()?; Ok(store) } + /// Modify account refresh timeout - how often they are re-read from `KeyDirectory`. + /// + /// Setting this to low values (or 0) will cause new accounts to be picked up quickly, + /// although it may induce heavy disk reads and is not recommended if you manage many keys (say over 10k). + /// + /// By default refreshing is disabled, so only accounts created using this instance of `EthStore` are taken into account. + pub fn set_refresh_time(&self, time: Duration) { + self.timestamp.lock().refresh_time = time; + } + fn reload_if_changed(&self) -> Result<(), Error> { let mut last_timestamp = self.timestamp.lock(); let now = Instant::now(); - if (now - last_timestamp.last_checked) > Duration::from_secs(REFRESH_TIME_SEC) { + if now - last_timestamp.last_checked > last_timestamp.refresh_time { let dir_hash = Some(self.dir.unique_repr()?); last_timestamp.last_checked = now; if last_timestamp.dir_hash == dir_hash { @@ -319,22 +340,23 @@ impl EthMultiStore { } fn get_accounts(&self, account: &StoreAccountRef) -> Result, Error> { - { + let from_cache = |account| { let cache = self.cache.read(); if let Some(accounts) = cache.get(account) { if !accounts.is_empty() { - return Ok(accounts.clone()) + return Some(accounts.clone()) } } - } - self.reload_if_changed()?; - let cache = self.cache.read(); - let accounts = cache.get(account).ok_or(Error::InvalidAccount)?; - if accounts.is_empty() { - Err(Error::InvalidAccount) - } else { - Ok(accounts.clone()) + None + }; + + match from_cache(account) { + Some(accounts) => Ok(accounts), + None => { + self.reload_if_changed()?; + from_cache(account).ok_or(Error::InvalidAccount) + } } } @@ -470,11 +492,20 @@ impl SimpleSecretStore for EthMultiStore { } fn account_ref(&self, address: &Address) -> Result { - use std::collections::Bound; - self.reload_if_changed()?; - let cache = self.cache.read(); - let mut r = cache.range((Bound::Included(*address), Bound::Included(*address))); - r.next().ok_or(Error::InvalidAccount).map(|(k, _)| k.clone()) + let read_from_cache = |address: &Address| { + use std::collections::Bound; + let cache = self.cache.read(); + let mut r = cache.range((Bound::Included(*address), Bound::Included(*address))); + r.next().map(|(k, _)| k.clone()) + }; + + match read_from_cache(address) { + Some(account) => Ok(account), + None => { + self.reload_if_changed()?; + read_from_cache(address).ok_or(Error::InvalidAccount) + } + } } fn accounts(&self) -> Result, Error> { diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 12ca31888..60d391ee9 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -335,6 +335,10 @@ usage! { "--keys-iterations=[NUM]", "Specify the number of iterations to use when deriving key from the password (bigger is more secure)", + ARG arg_accounts_refresh: (u64) = 5u64, or |c: &Config| otry!(c.account).refresh_time.clone(), + "--accounts-refresh=[TIME]", + "Specify the cache time of accounts read from disk. If you manage thousands of accounts set this to 0 to disable refresh.", + ARG arg_unlock: (Option) = None, or |c: &Config| otry!(c.account).unlock.as_ref().map(|vec| vec.join(",")), "--unlock=[ACCOUNTS]", "Unlock ACCOUNTS for the duration of the execution. ACCOUNTS is a comma-delimited list of addresses. Implies --no-ui.", @@ -1009,6 +1013,7 @@ struct Account { unlock: Option>, password: Option>, keys_iterations: Option, + refresh_time: Option, disable_hardware: Option, fast_unlock: Option, } @@ -1428,6 +1433,7 @@ mod tests { arg_unlock: Some("0xdeadbeefcafe0000000000000000000000000000".into()), arg_password: vec!["~/.safe/password.file".into()], arg_keys_iterations: 10240u32, + arg_accounts_refresh: 5u64, flag_no_hardware_wallets: false, flag_fast_unlock: false, @@ -1665,6 +1671,7 @@ mod tests { unlock: Some(vec!["0x1".into(), "0x2".into(), "0x3".into()]), password: Some(vec!["passwdfile path".into()]), keys_iterations: None, + refresh_time: None, disable_hardware: None, fast_unlock: None, }), diff --git a/parity/configuration.rs b/parity/configuration.rs index b912689eb..72d667062 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -484,6 +484,7 @@ impl Configuration { fn accounts_config(&self) -> Result { let cfg = AccountsConfig { iterations: self.args.arg_keys_iterations, + refresh_time: self.args.arg_accounts_refresh, testnet: self.args.flag_testnet, password_files: self.args.arg_password.clone(), unlocked_accounts: to_addresses(&self.args.arg_unlock)?, diff --git a/parity/params.rs b/parity/params.rs index fd94954f9..4a768e07d 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -188,6 +188,7 @@ impl str::FromStr for ResealPolicy { #[derive(Debug, PartialEq)] pub struct AccountsConfig { pub iterations: u32, + pub refresh_time: u64, pub testnet: bool, pub password_files: Vec, pub unlocked_accounts: Vec
, @@ -199,6 +200,7 @@ impl Default for AccountsConfig { fn default() -> Self { AccountsConfig { iterations: 10240, + refresh_time: 5, testnet: false, password_files: Vec::new(), unlocked_accounts: Vec::new(), diff --git a/parity/run.rs b/parity/run.rs index 13c3575d9..f3a2b4f43 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -909,9 +909,15 @@ fn prepare_account_provider(spec: &SpecType, dirs: &Directories, data_dir: &str, ], }, }; + + let ethstore = EthStore::open_with_iterations(dir, cfg.iterations).map_err(|e| format!("Could not open keys directory: {}", e))?; + if cfg.refresh_time > 0 { + ethstore.set_refresh_time(::std::time::Duration::from_secs(cfg.refresh_time)); + } let account_provider = AccountProvider::new( - Box::new(EthStore::open_with_iterations(dir, cfg.iterations).map_err(|e| format!("Could not open keys directory: {}", e))?), - account_settings); + Box::new(ethstore), + account_settings, + ); for a in cfg.unlocked_accounts { // Check if the account exists From d80dd81d7799a63ab68507e0c1a36d01bf0b6826 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 22 Dec 2017 09:37:39 -0400 Subject: [PATCH 10/14] parity-version pr reopen (#7136) * parity-version module split from util removed unused util deps and features trigger buildbot again only kvdb links rocksdb snappy linker issues * rm snappy * fixed old version imports --- Cargo.lock | 32 +++++++++++----------- Cargo.toml | 2 +- dapps/Cargo.toml | 1 + dapps/src/handlers/content.rs | 2 +- dapps/src/lib.rs | 1 + ethcore/src/state/account.rs | 9 +++++++ parity/cli/usage.rs | 2 +- parity/configuration.rs | 3 ++- parity/helpers.rs | 2 +- parity/main.rs | 1 + parity/params.rs | 3 ++- parity/run.rs | 2 +- rpc/Cargo.toml | 1 + rpc/src/lib.rs | 1 + rpc/src/v1/impls/light/parity.rs | 2 +- rpc/src/v1/impls/parity.rs | 2 +- rpc/src/v1/impls/web3.rs | 2 +- rpc/src/v1/tests/mocked/parity.rs | 4 +-- rpc/src/v1/tests/mocked/web3.rs | 2 +- updater/Cargo.toml | 1 + updater/src/lib.rs | 1 + updater/src/types/version_info.rs | 2 +- updater/src/updater.rs | 4 +-- util/Cargo.toml | 34 ++++-------------------- util/src/lib.rs | 23 ---------------- util/version/Cargo.toml | 14 ++++++++++ util/{ => version}/build.rs | 2 +- util/{src/misc.rs => version/src/lib.rs} | 15 ++++------- 28 files changed, 74 insertions(+), 96 deletions(-) create mode 100644 util/version/Cargo.toml rename util/{ => version}/build.rs (97%) rename util/{src/misc.rs => version/src/lib.rs} (93%) diff --git a/Cargo.lock b/Cargo.lock index e1104596a..55e88f5e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,31 +715,14 @@ dependencies = [ name = "ethcore-util" version = "1.9.0" dependencies = [ - "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", - "ethcore-logger 1.9.0", "hashdb 0.1.1", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "journaldb 0.1.0", "keccak-hash 0.1.0", - "kvdb 0.1.0", - "kvdb-memorydb 0.1.0", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.1", - "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", - "rlp 0.2.1", - "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "triehash 0.1.0", - "util-error 0.1.0", - "vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1938,6 +1921,7 @@ dependencies = [ "parity-rpc 1.9.0", "parity-rpc-client 1.4.0", "parity-updater 1.9.0", + "parity-version 0.1.0", "parity-whisper 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", @@ -1983,6 +1967,7 @@ dependencies = [ "parity-hash-fetch 1.9.0", "parity-reactor 0.1.0", "parity-ui 1.9.0", + "parity-version 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2130,6 +2115,7 @@ dependencies = [ "order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-reactor 0.1.0", "parity-updater 1.9.0", + "parity-version 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2237,12 +2223,24 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-hash-fetch 1.9.0", "parity-reactor 0.1.0", + "parity-version 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-version" +version = "0.1.0" +dependencies = [ + "ethcore-bytes 0.1.0", + "rlp 0.2.1", + "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parity-wasm" version = "0.15.3" diff --git a/Cargo.toml b/Cargo.toml index 31a0c1d28..a79dafd3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ parity-reactor = { path = "util/reactor" } parity-rpc = { path = "rpc" } parity-rpc-client = { path = "rpc_client" } parity-updater = { path = "updater" } +parity-version = { path = "util/version" } parity-whisper = { path = "whisper" } path = { path = "util/path" } panic_hook = { path = "panic_hook" } @@ -98,7 +99,6 @@ test-heavy = ["ethcore/test-heavy"] evm-debug = ["ethcore/evm-debug"] evm-debug-tests = ["ethcore/evm-debug-tests"] slow-blocks = ["ethcore/slow-blocks"] -final = ["ethcore-util/final"] secretstore = ["ethcore-secretstore"] [[bin]] diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index f44bc2d92..ac9becaa6 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -37,6 +37,7 @@ parity-hash-fetch = { path = "../hash-fetch" } parity-reactor = { path = "../util/reactor" } parity-ui = { path = "./ui" } keccak-hash = { path = "../util/hash" } +parity-version = { path = "../util/version" } [dev-dependencies] env_logger = "0.4" diff --git a/dapps/src/handlers/content.rs b/dapps/src/handlers/content.rs index 13d1fb0b9..711a985bd 100644 --- a/dapps/src/handlers/content.rs +++ b/dapps/src/handlers/content.rs @@ -19,7 +19,7 @@ use hyper::{self, mime, header}; use hyper::StatusCode; -use util::version; +use parity_version::version; use handlers::add_security_headers; use Embeddable; diff --git a/dapps/src/lib.rs b/dapps/src/lib.rs index 0d9a33aa7..19dd7f70b 100644 --- a/dapps/src/lib.rs +++ b/dapps/src/lib.rs @@ -41,6 +41,7 @@ extern crate parity_dapps_glue as parity_dapps; extern crate parity_hash_fetch as hash_fetch; extern crate parity_ui; extern crate keccak_hash as hash; +extern crate parity_version; #[macro_use] extern crate futures; diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 2d9a37e81..f4b6f0b4b 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -35,6 +35,15 @@ use std::cell::{RefCell, Cell}; const STORAGE_CACHE_ITEMS: usize = 8192; +/// Boolean type for clean/dirty status. +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub enum Filth { + /// Data has not been changed. + Clean, + /// Data has been changed. + Dirty, +} + /// Single account in the system. /// Keeps track of changes to the code and storage. /// The changes are applied in `commit_storage` and `commit_code` diff --git a/parity/cli/usage.rs b/parity/cli/usage.rs index 71ac01295..388afd1c1 100644 --- a/parity/cli/usage.rs +++ b/parity/cli/usage.rs @@ -152,7 +152,7 @@ macro_rules! usage { use toml; use std::{fs, io, process}; use std::io::{Read, Write}; - use util::version; + use parity_version::version; use clap::{Arg, App, SubCommand, AppSettings, ArgMatches as ClapArgMatches, Error as ClapError, ErrorKind as ClapErrorKind}; use helpers::replace_home; use std::ffi::OsStr; diff --git a/parity/configuration.rs b/parity/configuration.rs index 72d667062..715e63db5 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -25,7 +25,8 @@ use cli::{Args, ArgsError}; use hash::keccak; use bigint::prelude::U256; use bigint::hash::H256; -use util::{version_data, Address, version}; +use util::Address; +use parity_version::{version_data, version}; use bytes::Bytes; use ansi_term::Colour; use ethsync::{NetworkConfiguration, validate_node_url, self}; diff --git a/parity/helpers.rs b/parity/helpers.rs index 68bcce93d..88ff333d9 100644 --- a/parity/helpers.rs +++ b/parity/helpers.rs @@ -213,7 +213,7 @@ pub fn default_network_config() -> ::ethsync::NetworkConfiguration { ip_filter: IpFilter::default(), reserved_nodes: Vec::new(), allow_non_reserved: true, - client_version: ::util::version(), + client_version: ::parity_version::version(), } } diff --git a/parity/main.rs b/parity/main.rs index 9ed01b6f7..c8ea6ead8 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -67,6 +67,7 @@ extern crate parity_local_store as local_store; extern crate parity_reactor; extern crate parity_rpc; extern crate parity_updater as updater; +extern crate parity_version; extern crate parity_whisper; extern crate path; extern crate rpc_cli; diff --git a/parity/params.rs b/parity/params.rs index 4a768e07d..2d5cb8a7d 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -17,7 +17,8 @@ use std::{str, fs, fmt}; use std::time::Duration; use bigint::prelude::U256; -use util::{Address, version_data}; +use util::Address; +use parity_version::version_data; use journaldb::Algorithm; use ethcore::spec::{Spec, SpecParams}; use ethcore::ethereum; diff --git a/parity/run.rs b/parity/run.rs index f3a2b4f43..064f02d34 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -39,7 +39,7 @@ use parity_reactor::EventLoop; use parity_rpc::{NetworkSettings, informant, is_major_importing}; use updater::{UpdatePolicy, Updater}; use ansi_term::Colour; -use util::version; +use parity_version::version; use parking_lot::{Condvar, Mutex}; use node_filter::NodeFilter; use journaldb::Algorithm; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 6fba076e8..17ac43bd4 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -54,6 +54,7 @@ fetch = { path = "../util/fetch" } node-health = { path = "../dapps/node-health" } parity-reactor = { path = "../util/reactor" } parity-updater = { path = "../updater" } +parity-version = { path = "../util/version" } rlp = { path = "../util/rlp" } stats = { path = "../util/stats" } vm = { path = "../ethcore/vm" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index d26a77c8e..f326cb381 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -62,6 +62,7 @@ extern crate fetch; extern crate node_health; extern crate parity_reactor; extern crate parity_updater as updater; +extern crate parity_version as version; extern crate rlp; extern crate stats; extern crate keccak_hash as hash; diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index 6987f8082..1be734df4 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use std::collections::{BTreeMap, HashSet}; -use util::misc::version_data; +use version::version_data; use crypto::{ecies, DEFAULT_MAC}; use ethkey::{Brain, Generator}; diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index b10659322..4cb02f9cb 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -20,7 +20,7 @@ use std::str::FromStr; use std::collections::{BTreeMap, HashSet}; use util::Address; -use util::misc::version_data; +use version::version_data; use crypto::{DEFAULT_MAC, ecies}; use ethkey::{Brain, Generator}; diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index 44055507f..6915af1d1 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -17,7 +17,7 @@ //! Web3 rpc implementation. use hash::keccak; use jsonrpc_core::Result; -use util::version; +use version::version; use v1::traits::Web3; use v1::types::{H256, Bytes}; diff --git a/rpc/src/v1/tests/mocked/parity.rs b/rpc/src/v1/tests/mocked/parity.rs index 9153a17b3..e25f3e4d3 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -234,14 +234,14 @@ fn rpc_parity_chain_id() { #[test] fn rpc_parity_default_extra_data() { - use util::misc; + use version::version_data; use bytes::ToPretty; let deps = Dependencies::new(); let io = deps.default_client(); let request = r#"{"jsonrpc": "2.0", "method": "parity_defaultExtraData", "params": [], "id": 1}"#; - let response = format!(r#"{{"jsonrpc":"2.0","result":"0x{}","id":1}}"#, misc::version_data().to_hex()); + let response = format!(r#"{{"jsonrpc":"2.0","result":"0x{}","id":1}}"#, version_data().to_hex()); assert_eq!(io.handle_request_sync(request), Some(response)); } diff --git a/rpc/src/v1/tests/mocked/web3.rs b/rpc/src/v1/tests/mocked/web3.rs index 46a83bb3d..aceb36e56 100644 --- a/rpc/src/v1/tests/mocked/web3.rs +++ b/rpc/src/v1/tests/mocked/web3.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . use jsonrpc_core::IoHandler; -use util::version; +use version::version; use v1::{Web3, Web3Client}; #[test] diff --git a/updater/Cargo.toml b/updater/Cargo.toml index a67559f68..ec1b99296 100644 --- a/updater/Cargo.toml +++ b/updater/Cargo.toml @@ -19,4 +19,5 @@ futures = "0.1" parking_lot = "0.4" parity-hash-fetch = { path = "../hash-fetch" } parity-reactor = { path = "../util/reactor" } +parity-version = { path = "../util/version" } path = { path = "../util/path" } diff --git a/updater/src/lib.rs b/updater/src/lib.rs index c0da3b6a1..73ebc7ec4 100644 --- a/updater/src/lib.rs +++ b/updater/src/lib.rs @@ -28,6 +28,7 @@ extern crate ethsync; extern crate futures; extern crate target_info; extern crate parity_reactor; +extern crate parity_version as version; extern crate path; extern crate semver; diff --git a/updater/src/types/version_info.rs b/updater/src/types/version_info.rs index 778e57087..ea9b44577 100644 --- a/updater/src/types/version_info.rs +++ b/updater/src/types/version_info.rs @@ -19,7 +19,7 @@ use std::fmt; use semver::{Version}; use bigint::hash::H160; -use util::misc::raw_package_info; +use version::raw_package_info; use types::ReleaseTrack; /// Version information of a particular release. diff --git a/updater/src/updater.rs b/updater/src/updater.rs index 91c9181f8..72ddaa7fe 100644 --- a/updater/src/updater.rs +++ b/updater/src/updater.rs @@ -34,7 +34,7 @@ use bigint::hash::{H160, H256}; use util::Address; use bytes::Bytes; use parking_lot::Mutex; -use util::misc; +use version; /// Filter for releases. #[derive(Debug, Eq, PartialEq, Clone)] @@ -115,7 +115,7 @@ fn platform() -> String { } else if cfg!(target_os = "linux") { format!("{}-unknown-linux-gnu", Target::arch()) } else { - misc::platform() + version::platform() } } diff --git a/util/Cargo.toml b/util/Cargo.toml index 964b19c8f..e60b3c8eb 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -5,39 +5,15 @@ license = "GPL-3.0" name = "ethcore-util" version = "1.9.0" authors = ["Parity Technologies "] -build = "build.rs" [dependencies] -log = "0.3" -env_logger = "0.4" -rustc-hex = "1.0" -eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } -elastic-array = "0.9" -rlp = { path = "rlp" } -heapsize = "0.4" -keccak-hash = { path = "hash" } -libc = "0.2.7" -target_info = "0.1" ethcore-bigint = { path = "bigint", features = ["heapsizeof"] } -parking_lot = "0.4" -tiny-keccak= "1.0" -ethcore-logger = { path = "../logger" } -triehash = { path = "triehash" } hashdb = { path = "hashdb" } -patricia-trie = { path = "patricia_trie" } -ethcore-bytes = { path = "bytes" } memorydb = { path = "memorydb" } -util-error = { path = "error" } -kvdb = { path = "kvdb" } -journaldb = { path = "journaldb" } [dev-dependencies] -kvdb-memorydb = { path = "kvdb-memorydb" } - -[features] -default = [] -final = [] - -[build-dependencies] -vergen = "0.1" -rustc_version = "0.1.0" +ethcore-bytes = { path = "bytes" } +keccak-hash = { path = "hash" } +log = "0.3" +patricia-trie = { path = "patricia_trie" } +triehash = { path = "triehash" } diff --git a/util/src/lib.rs b/util/src/lib.rs index 18a95e470..4094ed967 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -70,33 +70,10 @@ //! cargo build --release //! ``` -extern crate rustc_hex; -extern crate env_logger; -extern crate secp256k1; -extern crate elastic_array; -extern crate libc; -extern crate target_info; extern crate ethcore_bigint as bigint; -extern crate ethcore_bytes as bytes; -extern crate parking_lot; -extern crate tiny_keccak; -extern crate rlp; -extern crate heapsize; -extern crate ethcore_logger; -extern crate keccak_hash as keccak; extern crate hashdb; extern crate memorydb; -extern crate patricia_trie as trie; -extern crate kvdb; -extern crate util_error as error; -#[cfg(test)] -extern crate kvdb_memorydb; - - -pub mod misc; - -pub use misc::*; pub use hashdb::*; pub use memorydb::MemoryDB; diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml new file mode 100644 index 000000000..22bf07fb1 --- /dev/null +++ b/util/version/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "parity-version" +version = "0.1.0" +authors = ["Parity Technologies "] +build = "build.rs" + +[dependencies] +ethcore-bytes = { path = "../bytes" } +rlp = { path = "../rlp" } +target_info = "0.1" + +[build-dependencies] +vergen = "0.1" +rustc_version = "0.1.0" diff --git a/util/build.rs b/util/version/build.rs similarity index 97% rename from util/build.rs rename to util/version/build.rs index 08ef81697..b5d3dd81d 100644 --- a/util/build.rs +++ b/util/version/build.rs @@ -17,11 +17,11 @@ extern crate vergen; extern crate rustc_version; -use vergen::*; use std::env; use std::fs::File; use std::io::Write; use std::path::Path; +use vergen::{vergen, OutputFns}; fn main() { vergen(OutputFns::all()).unwrap(); diff --git a/util/src/misc.rs b/util/version/src/lib.rs similarity index 93% rename from util/src/misc.rs rename to util/version/src/lib.rs index 6a1a11708..236f11914 100644 --- a/util/src/misc.rs +++ b/util/version/src/lib.rs @@ -16,9 +16,13 @@ //! Diff misc. -use rlp::RlpStream; +extern crate target_info; +extern crate ethcore_bytes as bytes; +extern crate rlp; + use target_info::Target; use bytes::Bytes; +use rlp::RlpStream; include!(concat!(env!("OUT_DIR"), "/version.rs")); include!(concat!(env!("OUT_DIR"), "/rustc_version.rs")); @@ -31,15 +35,6 @@ const THIS_TRACK: &'static str = "nightly"; const THIS_TRACK: &'static str = "unstable"; // ^^^ This gets used when we're not building a final release; should stay as "unstable". -/// Boolean type for clean/dirty status. -#[derive(PartialEq, Eq, Clone, Copy, Debug)] -pub enum Filth { - /// Data has not been changed. - Clean, - /// Data has been changed. - Dirty, -} - /// Get the platform identifier. pub fn platform() -> String { let env = Target::env(); From 82340c058a531304afcaac97dfc90eb1b1c82a25 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Fri, 22 Dec 2017 21:54:35 +0300 Subject: [PATCH 11/14] Wasm runtime update (#7356) * call augmented, wasm-tests updated * fix all call tests * fix comments --- ethcore/res/wasm-tests | 2 +- ethcore/wasm/src/env.rs | 6 +-- ethcore/wasm/src/lib.rs | 1 + ethcore/wasm/src/runtime.rs | 29 +++++++---- ethcore/wasm/src/tests.rs | 99 +++++++++++++++++++++++++++---------- 5 files changed, 97 insertions(+), 40 deletions(-) diff --git a/ethcore/res/wasm-tests b/ethcore/res/wasm-tests index d6185ea16..d9d6133c1 160000 --- a/ethcore/res/wasm-tests +++ b/ethcore/res/wasm-tests @@ -1 +1 @@ -Subproject commit d6185ea16eaba7ff685c069c2064819f9549c4d7 +Subproject commit d9d6133c1bc5dca4c74c9eb758a39546a0d46b45 diff --git a/ethcore/wasm/src/env.rs b/ethcore/wasm/src/env.rs index ed4bda68b..cae673858 100644 --- a/ethcore/wasm/src/env.rs +++ b/ethcore/wasm/src/env.rs @@ -69,17 +69,17 @@ pub const SIGNATURES: &'static [UserFunctionDescriptor] = &[ ), Static( "_ccall", - &[I32; 6], + &[I64, I32, I32, I32, I32, I32, I32], Some(I32), ), Static( "_dcall", - &[I32; 5], + &[I64, I32, I32, I32, I32, I32], Some(I32), ), Static( "_scall", - &[I32; 5], + &[I64, I32, I32, I32, I32, I32], Some(I32), ), Static( diff --git a/ethcore/wasm/src/lib.rs b/ethcore/wasm/src/lib.rs index 30ce03665..5b4e59fcb 100644 --- a/ethcore/wasm/src/lib.rs +++ b/ethcore/wasm/src/lib.rs @@ -111,6 +111,7 @@ impl vm::Vm for WasmInterpreter { address: params.address, sender: params.sender, origin: params.origin, + code_address: params.code_address, value: params.value.value(), }, &self.program, diff --git a/ethcore/wasm/src/runtime.rs b/ethcore/wasm/src/runtime.rs index bad325fbf..700233951 100644 --- a/ethcore/wasm/src/runtime.rs +++ b/ethcore/wasm/src/runtime.rs @@ -104,6 +104,7 @@ pub struct RuntimeContext { pub address: Address, pub sender: Address, pub origin: Address, + pub code_address: Address, pub value: U256, } @@ -305,6 +306,7 @@ impl<'a, 'b> Runtime<'a, 'b> { // // method signature: // fn ( + // gas: i64, // address: *const u8, // val_ptr: *const u8, // input_ptr: *const u8, @@ -323,6 +325,7 @@ impl<'a, 'b> Runtime<'a, 'b> { // // signature (same as static call): // fn ( + // gas: i64, // address: *const u8, // input_ptr: *const u8, // input_len: u32, @@ -330,7 +333,7 @@ impl<'a, 'b> Runtime<'a, 'b> { // result_len: u32, // ) -> i32 - self.do_call(false, CallType::CallCode, context) + self.do_call(false, CallType::DelegateCall, context) } fn do_call( @@ -363,6 +366,9 @@ impl<'a, 'b> Runtime<'a, 'b> { let address = self.pop_address(&mut context)?; trace!(target: "wasm", " address: {:?}", address); + let gas = context.value_stack.pop_as::()? as u64; + trace!(target: "wasm", " gas: {:?}", gas); + if let Some(ref val) = val { let address_balance = self.ext.balance(&self.context.address) .map_err(|_| UserTrap::BalanceQueryError)?; @@ -377,16 +383,16 @@ impl<'a, 'b> Runtime<'a, 'b> { let mut result = Vec::with_capacity(result_alloc_len as usize); result.resize(result_alloc_len as usize, 0); - let gas = self.gas_left() - .map_err(|_| UserTrap::InvalidGasState)? - .into(); + // todo: optimize to use memory views once it's in let payload = self.memory.get(input_ptr, input_len as usize)?; + self.charge(|_| gas.into())?; + let call_result = self.ext.call( - &gas, - &self.context.sender, - &self.context.address, + &gas.into(), + match call_type { CallType::DelegateCall => &self.context.sender, _ => &self.context.address }, + match call_type { CallType::Call | CallType::StaticCall => &address, _ => &self.context.address }, val, &payload, &address, @@ -396,12 +402,16 @@ impl<'a, 'b> Runtime<'a, 'b> { match call_result { vm::MessageCallResult::Success(gas_left, _) => { - self.gas_counter = self.gas_limit - gas_left.low_u64(); + // cannot overflow, before making call gas_counter was incremented with gas, and gas_left < gas + self.gas_counter = self.gas_counter - gas_left.low_u64(); + self.memory.set(result_ptr, &result)?; Ok(Some(0i32.into())) }, vm::MessageCallResult::Reverted(gas_left, _) => { - self.gas_counter = self.gas_limit - gas_left.low_u64(); + // cannot overflow, before making call gas_counter was incremented with gas, and gas_left < gas + self.gas_counter = self.gas_counter - gas_left.low_u64(); + self.memory.set(result_ptr, &result)?; Ok(Some((-1i32).into())) }, @@ -416,6 +426,7 @@ impl<'a, 'b> Runtime<'a, 'b> { { // signature (same as code call): // fn ( + // gas: i64, // address: *const u8, // input_ptr: *const u8, // input_len: u32, diff --git a/ethcore/wasm/src/tests.rs b/ethcore/wasm/src/tests.rs index a387f9292..115199aeb 100644 --- a/ethcore/wasm/src/tests.rs +++ b/ethcore/wasm/src/tests.rs @@ -60,7 +60,7 @@ fn empty() { test_finalize(interpreter.exec(params, &mut ext)).unwrap() }; - assert_eq!(gas_left, U256::from(99_982)); + assert_eq!(gas_left, U256::from(96_678)); } // This test checks if the contract deserializes payload header properly. @@ -112,7 +112,7 @@ fn logger() { U256::from(1_000_000_000), "Logger sets 0x04 key to the trasferred value" ); - assert_eq!(gas_left, U256::from(19_147)); + assert_eq!(gas_left, U256::from(15_860)); } // This test checks if the contract can allocate memory and pass pointer to the result stream properly. @@ -147,7 +147,7 @@ fn identity() { sender, "Idenity test contract does not return the sender passed" ); - assert_eq!(gas_left, U256::from(99_844)); + assert_eq!(gas_left, U256::from(96_540)); } // Dispersion test sends byte array and expect the contract to 'disperse' the original elements with @@ -180,7 +180,7 @@ fn dispersion() { result, vec![0u8, 0, 125, 11, 197, 7, 255, 8, 19, 0] ); - assert_eq!(gas_left, U256::from(96_393)); + assert_eq!(gas_left, U256::from(96_116)); } #[test] @@ -208,7 +208,7 @@ fn suicide_not() { result, vec![0u8] ); - assert_eq!(gas_left, U256::from(96_725)); + assert_eq!(gas_left, U256::from(96_461)); } #[test] @@ -240,7 +240,7 @@ fn suicide() { }; assert!(ext.suicides.contains(&refund)); - assert_eq!(gas_left, U256::from(96_687)); + assert_eq!(gas_left, U256::from(96_429)); } #[test] @@ -270,7 +270,7 @@ fn create() { assert!(ext.calls.contains( &FakeCall { call_type: FakeCallType::Create, - gas: U256::from(65_899), + gas: U256::from(62_545), sender_address: None, receive_address: None, value: Some(1_000_000_000.into()), @@ -278,9 +278,52 @@ fn create() { code_address: None, } )); - assert_eq!(gas_left, U256::from(65_892)); + assert_eq!(gas_left, U256::from(62_538)); } +#[test] +fn call_msg() { + ::ethcore_logger::init_log(); + + let sender: Address = "01030507090b0d0f11131517191b1d1f21232527".parse().unwrap(); + let receiver: Address = "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6".parse().unwrap(); + let contract_address: Address = "0d461d4174b4ae35775c4a342f1e5e1e4e6c4db5".parse().unwrap(); + + let mut params = ActionParams::default(); + params.sender = sender.clone(); + params.address = receiver.clone(); + params.code_address = contract_address.clone(); + params.gas = U256::from(100_000); + params.code = Some(Arc::new(load_sample!("call.wasm"))); + params.data = Some(Vec::new()); + + let mut ext = FakeExt::new(); + ext.balances.insert(receiver.clone(), U256::from(10000000000u64)); + + let gas_left = { + let mut interpreter = wasm_interpreter(); + let result = interpreter.exec(params, &mut ext).expect("Interpreter to execute without any errors"); + match result { + GasLeft::Known(gas_left) => gas_left, + GasLeft::NeedsReturn { .. } => { panic!("Call test should not return payload"); }, + } + }; + + trace!(target: "wasm", "fake_calls: {:?}", &ext.calls); + assert!(ext.calls.contains( + &FakeCall { + call_type: FakeCallType::Call, + gas: U256::from(33_000), + sender_address: Some(receiver), + receive_address: Some(Address::from([99, 88, 77, 66, 55, 44, 33, 22, 11, 0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 0])), + value: Some(1000000000.into()), + data: vec![129u8, 123, 113, 107, 101, 97], + code_address: Some(Address::from([99, 88, 77, 66, 55, 44, 33, 22, 11, 0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 0])), + } + )); + + assert_eq!(gas_left, U256::from(95_699)); +} #[test] fn call_code() { @@ -312,7 +355,7 @@ fn call_code() { assert!(ext.calls.contains( &FakeCall { call_type: FakeCallType::Call, - gas: U256::from(98_713), + gas: U256::from(20_000), sender_address: Some(sender), receive_address: Some(receiver), value: None, @@ -324,7 +367,7 @@ fn call_code() { // siphash result let res = LittleEndian::read_u32(&result[..]); assert_eq!(res, 4198595614); - assert_eq!(gas_left, U256::from(93_855)); + assert_eq!(gas_left, U256::from(90_550)); } #[test] @@ -333,6 +376,7 @@ fn call_static() { let sender: Address = "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6".parse().unwrap(); let receiver: Address = "01030507090b0d0f11131517191b1d1f21232527".parse().unwrap(); + let contract_address: Address = "0d461d4174b4ae35775c4a342f1e5e1e4e6c4db5".parse().unwrap(); let mut params = ActionParams::default(); params.sender = sender.clone(); @@ -341,6 +385,7 @@ fn call_static() { params.code = Some(Arc::new(load_sample!("call_static.wasm"))); params.data = Some(Vec::new()); params.value = ActionValue::transfer(1_000_000_000); + params.code_address = contract_address.clone(); let mut ext = FakeExt::new(); @@ -357,9 +402,9 @@ fn call_static() { assert!(ext.calls.contains( &FakeCall { call_type: FakeCallType::Call, - gas: U256::from(98_713), - sender_address: Some(sender), - receive_address: Some(receiver), + gas: U256::from(20_000), + sender_address: Some(receiver), + receive_address: Some("13077bfb00000000000000000000000000000000".parse().unwrap()), value: None, data: vec![1u8, 2, 3, 5, 7, 11], code_address: Some("13077bfb00000000000000000000000000000000".parse().unwrap()), @@ -370,7 +415,7 @@ fn call_static() { let res = LittleEndian::read_u32(&result[..]); assert_eq!(res, 317632590); - assert_eq!(gas_left, U256::from(93_855)); + assert_eq!(gas_left, U256::from(90_550)); } // Realloc test @@ -393,7 +438,7 @@ fn realloc() { } }; assert_eq!(result, vec![0u8; 2]); - assert_eq!(gas_left, U256::from(96_723)); + assert_eq!(gas_left, U256::from(96_445)); } // Tests that contract's ability to read from a storage @@ -419,7 +464,7 @@ fn storage_read() { }; assert_eq!(Address::from(&result[12..32]), address); - assert_eq!(gas_left, U256::from(99_767)); + assert_eq!(gas_left, U256::from(96_463)); } // Tests keccak calculation @@ -445,7 +490,7 @@ fn keccak() { }; assert_eq!(H256::from_slice(&result), H256::from("68371d7e884c168ae2022c82bd837d51837718a7f7dfb7aa3f753074a35e1d87")); - assert_eq!(gas_left, U256::from(81_446)); + assert_eq!(gas_left, U256::from(81_067)); } // memcpy test. @@ -477,7 +522,7 @@ fn memcpy() { }; assert_eq!(result, test_payload); - assert_eq!(gas_left, U256::from(72_216)); + assert_eq!(gas_left, U256::from(71_940)); } // memmove test. @@ -509,7 +554,7 @@ fn memmove() { }; assert_eq!(result, test_payload); - assert_eq!(gas_left, U256::from(72_216)); + assert_eq!(gas_left, U256::from(71_940)); } // memset test @@ -534,7 +579,7 @@ fn memset() { }; assert_eq!(result, vec![228u8; 8192]); - assert_eq!(gas_left, U256::from(72_196)); + assert_eq!(gas_left, U256::from(71_921)); } macro_rules! reqrep_test { @@ -591,7 +636,7 @@ fn math_add() { U256::from_dec_str("1888888888888888888888888888887").unwrap(), (&result[..]).into() ); - assert_eq!(gas_left, U256::from(95_524)); + assert_eq!(gas_left, U256::from(95_384)); } // multiplication @@ -613,7 +658,7 @@ fn math_mul() { U256::from_dec_str("888888888888888888888888888887111111111111111111111111111112").unwrap(), (&result[..]).into() ); - assert_eq!(gas_left, U256::from(94_674)); + assert_eq!(gas_left, U256::from(94_374)); } // subtraction @@ -635,7 +680,7 @@ fn math_sub() { U256::from_dec_str("111111111111111111111111111111").unwrap(), (&result[..]).into() ); - assert_eq!(gas_left, U256::from(95_516)); + assert_eq!(gas_left, U256::from(95_372)); } // subtraction with overflow @@ -677,7 +722,7 @@ fn math_div() { U256::from_dec_str("1125000").unwrap(), (&result[..]).into() ); - assert_eq!(gas_left, U256::from(88_514)); + assert_eq!(gas_left, U256::from(88_356)); } // This test checks the ability of wasm contract to invoke @@ -765,7 +810,7 @@ fn externs() { "Gas limit requested and returned does not match" ); - assert_eq!(gas_left, U256::from(94_858)); + assert_eq!(gas_left, U256::from(95_321)); } #[test] @@ -791,7 +836,7 @@ fn embedded_keccak() { }; assert_eq!(H256::from_slice(&result), H256::from("68371d7e884c168ae2022c82bd837d51837718a7f7dfb7aa3f753074a35e1d87")); - assert_eq!(gas_left, U256::from(81_446)); + assert_eq!(gas_left, U256::from(81_067)); } /// This test checks the correctness of log extern @@ -826,5 +871,5 @@ fn events() { assert_eq!(&log_entry.data, b"gnihtemos"); assert_eq!(&result, b"gnihtemos"); - assert_eq!(gas_left, U256::from(79_637)); + assert_eq!(gas_left, U256::from(79_206)); } From 74d2896397141c816e93de6b586683246c6c9a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 27 Dec 2017 11:02:39 +0100 Subject: [PATCH 12/14] Fix version. --- util/version/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml index 22bf07fb1..44f5a08f2 100644 --- a/util/version/Cargo.toml +++ b/util/version/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "parity-version" -version = "0.1.0" +# NOTE: this value is used for Parity version string. +version = "1.9.0" authors = ["Parity Technologies "] build = "build.rs" From 5b5dd85cf9687c908fa89c1f12b8bd1a06c3e3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 27 Dec 2017 11:32:05 +0100 Subject: [PATCH 13/14] Fix lock file. --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55e88f5e3..c3480664e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1921,7 +1921,7 @@ dependencies = [ "parity-rpc 1.9.0", "parity-rpc-client 1.4.0", "parity-updater 1.9.0", - "parity-version 0.1.0", + "parity-version 1.9.0", "parity-whisper 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", @@ -1967,7 +1967,7 @@ dependencies = [ "parity-hash-fetch 1.9.0", "parity-reactor 0.1.0", "parity-ui 1.9.0", - "parity-version 0.1.0", + "parity-version 1.9.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2115,7 +2115,7 @@ dependencies = [ "order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-reactor 0.1.0", "parity-updater 1.9.0", - "parity-version 0.1.0", + "parity-version 1.9.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2223,7 +2223,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-hash-fetch 1.9.0", "parity-reactor 0.1.0", - "parity-version 0.1.0", + "parity-version 1.9.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2232,7 +2232,7 @@ dependencies = [ [[package]] name = "parity-version" -version = "0.1.0" +version = "1.9.0" dependencies = [ "ethcore-bytes 0.1.0", "rlp 0.2.1", From 26e4fc680c7bbe5654ba65627af5e6852f8a8235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 27 Dec 2017 18:56:06 +0100 Subject: [PATCH 14/14] Fix default CORS settings. (#7387) * Fix default CORS settings. * Add info regarding special options. --- parity/cli/mod.rs | 16 ++++++++-------- parity/cli/tests/config.full.toml | 6 +++--- parity/configuration.rs | 20 +++++++++++++------- parity/ipfs.rs | 4 ++-- parity/rpc.rs | 6 +++--- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 60d391ee9..b225ee189 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -466,9 +466,9 @@ usage! { "--jsonrpc-threads=[THREADS]", "Turn on additional processing threads in all RPC servers. Setting this to non-zero value allows parallel cpu-heavy queries execution.", - ARG arg_jsonrpc_cors: (Option) = None, or |c: &Config| otry!(c.rpc).cors.clone(), + ARG arg_jsonrpc_cors: (String) = "none", or |c: &Config| otry!(c.rpc).cors.as_ref().map(|vec| vec.join(",")), "--jsonrpc-cors=[URL]", - "Specify CORS header for JSON-RPC API responses.", + "Specify CORS header for JSON-RPC API responses. Special options: \"all\", \"none\".", ARG arg_jsonrpc_server_threads: (Option) = None, or |c: &Config| otry!(c.rpc).server_threads, "--jsonrpc-server-threads=[NUM]", @@ -538,9 +538,9 @@ usage! { "--ipfs-api-hosts=[HOSTS]", "List of allowed Host header values. This option will validate the Host header sent by the browser, it is additional security against some attack vectors. Special options: \"all\", \"none\".", - ARG arg_ipfs_api_cors: (Option) = None, or |c: &Config| otry!(c.ipfs).cors.clone(), + ARG arg_ipfs_api_cors: (String) = "none", or |c: &Config| otry!(c.ipfs).cors.as_ref().map(|vec| vec.join(",")), "--ipfs-api-cors=[URL]", - "Specify CORS header for IPFS API responses.", + "Specify CORS header for IPFS API responses. Special options: \"all\", \"none\".", ["Secret store options"] FLAG flag_no_secretstore: (bool) = false, or |c: &Config| otry!(c.secretstore).disable.clone(), @@ -1052,7 +1052,7 @@ struct Rpc { disable: Option, port: Option, interface: Option, - cors: Option, + cors: Option>, apis: Option>, hosts: Option>, server_threads: Option, @@ -1108,7 +1108,7 @@ struct Ipfs { enable: Option, port: Option, interface: Option, - cors: Option, + cors: Option>, hosts: Option>, } @@ -1468,7 +1468,7 @@ mod tests { flag_no_jsonrpc: false, arg_jsonrpc_port: 8545u16, arg_jsonrpc_interface: "local".into(), - arg_jsonrpc_cors: Some("null".into()), + arg_jsonrpc_cors: "null".into(), arg_jsonrpc_apis: "web3,eth,net,parity,traces,rpc,secretstore".into(), arg_jsonrpc_hosts: "none".into(), arg_jsonrpc_server_threads: None, @@ -1507,7 +1507,7 @@ mod tests { flag_ipfs_api: false, arg_ipfs_api_port: 5001u16, arg_ipfs_api_interface: "local".into(), - arg_ipfs_api_cors: Some("null".into()), + arg_ipfs_api_cors: "null".into(), arg_ipfs_api_hosts: "none".into(), // -- Sealing/Mining Options diff --git a/parity/cli/tests/config.full.toml b/parity/cli/tests/config.full.toml index a49717085..6502da1a2 100644 --- a/parity/cli/tests/config.full.toml +++ b/parity/cli/tests/config.full.toml @@ -49,7 +49,7 @@ reserved_peers = "./path_to_file" disable = false port = 8545 interface = "local" -cors = "null" +cors = ["null"] apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"] hosts = ["none"] @@ -76,7 +76,7 @@ path = "$HOME/.parity/dapps" user = "test_user" pass = "test_pass" -[secretstore] +[secretstore] disable = false disable_http = false disable_acl_check = false @@ -91,7 +91,7 @@ path = "$HOME/.parity/secretstore" enable = false port = 5001 interface = "local" -cors = "null" +cors = ["null"] hosts = ["none"] [mining] diff --git a/parity/configuration.rs b/parity/configuration.rs index 715e63db5..93a39bc6f 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -775,13 +775,19 @@ impl Configuration { apis.join(",") } - fn cors(cors: Option<&String>) -> Option> { - cors.map(|ref c| c.split(',').map(Into::into).collect()) + fn cors(cors: &str) -> Option> { + match cors { + "none" => return Some(Vec::new()), + "*" | "all" | "any" => return None, + _ => {}, + } + + Some(cors.split(',').map(Into::into).collect()) } fn rpc_cors(&self) -> Option> { - let cors = self.args.arg_jsonrpc_cors.as_ref().or(self.args.arg_rpccorsdomain.as_ref()); - Self::cors(cors) + let cors = self.args.arg_rpccorsdomain.clone().unwrap_or_else(|| self.args.arg_jsonrpc_cors.to_owned()); + Self::cors(&cors) } fn ipfs_cors(&self) -> Option> { @@ -1458,7 +1464,7 @@ mod tests { assert_eq!(net.rpc_enabled, true); assert_eq!(net.rpc_interface, "0.0.0.0".to_owned()); assert_eq!(net.rpc_port, 8000); - assert_eq!(conf.rpc_cors(), Some(vec!["*".to_owned()])); + assert_eq!(conf.rpc_cors(), None); assert_eq!(conf.rpc_apis(), "web3,eth".to_owned()); } @@ -1525,8 +1531,8 @@ mod tests { let conf2 = parse(&["parity", "--ipfs-api-cors", "http://parity.io,http://something.io"]); // then - assert_eq!(conf0.ipfs_cors(), None); - assert_eq!(conf1.ipfs_cors(), Some(vec!["*".into()])); + assert_eq!(conf0.ipfs_cors(), Some(vec![])); + assert_eq!(conf1.ipfs_cors(), None); assert_eq!(conf2.ipfs_cors(), Some(vec!["http://parity.io".into(),"http://something.io".into()])); } diff --git a/parity/ipfs.rs b/parity/ipfs.rs index 45c3f7062..ac9a4662b 100644 --- a/parity/ipfs.rs +++ b/parity/ipfs.rs @@ -34,8 +34,8 @@ impl Default for Configuration { enabled: false, port: 5001, interface: "127.0.0.1".into(), - cors: None, - hosts: Some(Vec::new()), + cors: Some(vec![]), + hosts: Some(vec![]), } } } diff --git a/parity/rpc.rs b/parity/rpc.rs index 3a202b590..d17b77ccd 100644 --- a/parity/rpc.rs +++ b/parity/rpc.rs @@ -59,8 +59,8 @@ impl Default for HttpConfiguration { interface: "127.0.0.1".into(), port: 8545, apis: ApiSet::UnsafeContext, - cors: None, - hosts: Some(Vec::new()), + cors: Some(vec![]), + hosts: Some(vec![]), server_threads: 1, processing_threads: 4, } @@ -98,7 +98,7 @@ impl From for HttpConfiguration { interface: conf.interface, port: conf.port, apis: rpc_apis::ApiSet::UnsafeContext, - cors: None, + cors: Some(vec![]), hosts: conf.hosts, server_threads: 1, processing_threads: 0,