diff --git a/CHANGELOG.md b/CHANGELOG.md index a459ac7afd0..467c0780248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,82 @@ +## Parity [v1.11.6](https://github.com/paritytech/parity/releases/tag/v1.11.6) (2018-07-09) + +Parity 1.11.6 is a bug-fix release to improve performance and stability. + +The full list of included changes: + +- Beta: 1.11.6 backports ([#9015](https://github.com/paritytech/parity/pull/9015)) + - Parity-version: bump beta to 1.11.6 + - Scripts: remove md5 checksums ([#8884](https://github.com/paritytech/parity/pull/8884)) + - Add support for --chain tobalaba + - Convert indents to tabs :) + - Fixes for misbehavior reporting in AuthorityRound ([#8998](https://github.com/paritytech/parity/pull/8998)) + - Aura: only report after checking for repeated skipped primaries + - Aura: refactor duplicate code for getting epoch validator set + - Aura: verify_external: report on validator set contract instance + - Aura: use correct validator set epoch number when reporting + - Aura: use epoch set when verifying blocks + - Aura: report skipped primaries when generating seal + - Aura: handle immediate transitions + - Aura: don't report skipped steps from genesis to first block + - Aura: fix reporting test + - Aura: refactor duplicate code to handle immediate_transitions + - Aura: let reporting fail on verify_block_basic + - Aura: add comment about possible failure of reporting + - Only return error log for rustls ([#9025](https://github.com/paritytech/parity/pull/9025)) + - Transaction Pool improvements ([#8470](https://github.com/paritytech/parity/pull/8470)) + - Don't use ethereum_types in transaction pool. + - Hide internal insertion_id. + - Fix tests. + - Review grumbles. + - Improve should_replace on NonceAndGasPrice ([#8980](https://github.com/paritytech/parity/pull/8980)) + - Additional tests for NonceAndGasPrice::should_replace. + - Fix should_replace in the distinct sender case. + - Use natural priority ordering to simplify should_replace. + - Minimal effective gas price in the queue ([#8934](https://github.com/paritytech/parity/pull/8934)) + - Minimal effective gas price. + - Fix naming, add test + - Fix minimal entry score and add test. + - Fix worst_transaction. + - Remove effective gas price threshold. + - Don't leak gas_price decisions out of Scoring. + - Never drop local transactions from different senders. ([#9002](https://github.com/paritytech/parity/pull/9002)) + - Recently rejected cache for transaction queue ([#9005](https://github.com/paritytech/parity/pull/9005)) + - Store recently rejected transactions. + - Don't cache AlreadyImported rejections. + - Make the size of transaction verification queue dependent on pool size. + - Add a test for recently rejected. + - Fix logging for recently rejected. + - Make rejection cache smaller. + - Obsolete test removed + - Obsolete test removed + - Construct cache with_capacity. + - Optimize pending transactions filter ([#9026](https://github.com/paritytech/parity/pull/9026)) + - Rpc: return unordered transactions in pending transactions filter + - Ethcore: use LruCache for nonce cache + - Only clear the nonce cache when a block is retracted + - Revert "ethcore: use LruCache for nonce cache" + - This reverts commit b382c19. + - Use only cached nonces when computing pending hashes. + - Give filters their own locks, so that they don't block one another. + - Fix pending transaction count if not sealing. + - Clear cache only when block is enacted. + - Fix RPC tests. + - Address review comments. + - A last bunch of txqueue performance optimizations ([#9024](https://github.com/paritytech/parity/pull/9024)) + - Clear cache only when block is enacted. + - Add tracing for cull. + - Cull split. + - Cull after creating pending block. + - Add constant, remove sync::read tracing. + - Reset debug. + - Remove excessive tracing. + - Use struct for NonceCache. + - Fix build + - Remove warnings. + - Fix build again. + - Miner: add missing macro use for trace_time + - Ci: remove md5 merge leftovers + ## Parity [v1.11.5](https://github.com/paritytech/parity/releases/tag/v1.11.5) (2018-06-29) Parity 1.11.5 is a bug-fix release to improve performance and stability. diff --git a/Cargo.lock b/Cargo.lock index b4363d181ec..f5b37a8fa66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -384,13 +384,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "dir" -version = "0.1.0" +version = "0.1.1" dependencies = [ "app_dirs 1.2.1 (git+https://github.com/paritytech/app-dirs-rs)", + "dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", ] +[[package]] +name = "dirs" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "docopt" version = "0.8.3" @@ -981,7 +991,7 @@ dependencies = [ name = "ethstore" version = "0.2.0" dependencies = [ - "dir 0.1.0", + "dir 0.1.1", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1006,7 +1016,7 @@ dependencies = [ name = "ethstore-cli" version = "0.1.0" dependencies = [ - "dir 0.1.0", + "dir 0.1.1", "docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethstore 0.2.0", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2027,7 +2037,7 @@ dependencies = [ "clap 2.29.1 (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 (git+https://github.com/paritytech/daemonize)", - "dir 0.1.0", + "dir 0.1.1", "docopt 0.8.3 (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.12.0", @@ -3890,6 +3900,7 @@ dependencies = [ "checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum daemonize 0.2.3 (git+https://github.com/paritytech/daemonize)" = "" "checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" +"checksum dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "37a76dd8b997af7107d0bb69d43903cf37153a18266f8b3fdb9911f28efb5444" "checksum docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d8acd393692c503b168471874953a2531df0e9ab77d0b6bbc582395743300a4a" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum edit-distance 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6a34f5204fbc13582de418611cf3a7dcdd07c6d312a5b631597ba72c06b9d9c9" diff --git a/docs/CHANGELOG-1.10.md b/docs/CHANGELOG-1.10.md index ca9f84776a6..caa440f6d77 100644 --- a/docs/CHANGELOG-1.10.md +++ b/docs/CHANGELOG-1.10.md @@ -1,3 +1,29 @@ +## Parity [v1.10.9](https://github.com/paritytech/parity/releases/tag/v1.10.9) (2018-07-07) + +Parity 1.10.9 is a bug-fix release to improve performance and stability. + +The full list of included changes: + +- Stable: 1.10.9 backports ([#9016](https://github.com/paritytech/parity/pull/9016)) + - Parity-version: bump stable to 1.10.9 + - Scripts: remove md5 checksums ([#8884](https://github.com/paritytech/parity/pull/8884)) + - Add support for --chain tobalaba ([#8870](https://github.com/paritytech/parity/pull/8870)) + - Add support for --chain tobalaba + - Only return error log for rustls ([#9025](https://github.com/paritytech/parity/pull/9025)) + - Fixes for misbehavior reporting in AuthorityRound ([#8998](https://github.com/paritytech/parity/pull/8998)) + - Aura: only report after checking for repeated skipped primaries + - Aura: refactor duplicate code for getting epoch validator set + - Aura: verify_external: report on validator set contract instance + - Aura: use correct validator set epoch number when reporting + - Aura: use epoch set when verifying blocks + - Aura: report skipped primaries when generating seal + - Aura: handle immediate transitions + - Aura: don't report skipped steps from genesis to first block + - Aura: fix reporting test + - Aura: refactor duplicate code to handle immediate_transitions + - Aura: let reporting fail on verify_block_basic + - Aura: add comment about possible failure of reporting + ## Parity [v1.10.8](https://github.com/paritytech/parity/releases/tag/v1.10.8) (2018-06-29) Parity 1.10.8 is a bug-fix release to improve performance and stability. diff --git a/ethash/src/cache.rs b/ethash/src/cache.rs index 21bd0e231ef..023e4bb468f 100644 --- a/ethash/src/cache.rs +++ b/ethash/src/cache.rs @@ -91,7 +91,7 @@ impl NodeCacheBuilder { pub fn new>>(optimize_for: T) -> Self { NodeCacheBuilder { - seedhash: Arc::new(Mutex::new(SeedHashCompute::new())), + seedhash: Arc::new(Mutex::new(SeedHashCompute::default())), optimize_for: optimize_for.into().unwrap_or_default(), } } diff --git a/ethash/src/seed_compute.rs b/ethash/src/seed_compute.rs index bc6f1d51e1b..7a3f89b9b5d 100644 --- a/ethash/src/seed_compute.rs +++ b/ethash/src/seed_compute.rs @@ -19,20 +19,13 @@ use keccak::{keccak_256, H256}; use std::cell::Cell; +#[derive(Default)] pub struct SeedHashCompute { prev_epoch: Cell, prev_seedhash: Cell, } impl SeedHashCompute { - #[inline] - pub fn new() -> SeedHashCompute { - SeedHashCompute { - prev_epoch: Cell::new(0), - prev_seedhash: Cell::new([0u8; 32]), - } - } - #[inline] fn reset_cache(&self) { self.prev_epoch.set(0); @@ -77,20 +70,20 @@ mod tests { #[test] fn test_seed_compute_once() { - let seed_compute = SeedHashCompute::new(); + let seed_compute = SeedHashCompute::default(); let hash = [241, 175, 44, 134, 39, 121, 245, 239, 228, 236, 43, 160, 195, 152, 46, 7, 199, 5, 253, 147, 241, 206, 98, 43, 3, 104, 17, 40, 192, 79, 106, 162]; assert_eq!(seed_compute.hash_block_number(486382), hash); } #[test] fn test_seed_compute_zero() { - let seed_compute = SeedHashCompute::new(); + let seed_compute = SeedHashCompute::default(); assert_eq!(seed_compute.hash_block_number(0), [0u8; 32]); } #[test] fn test_seed_compute_after_older() { - let seed_compute = SeedHashCompute::new(); + let seed_compute = SeedHashCompute::default(); // calculating an older value first shouldn't affect the result let _ = seed_compute.hash_block_number(50000); let hash = [241, 175, 44, 134, 39, 121, 245, 239, 228, 236, 43, 160, 195, 152, 46, 7, 199, 5, 253, 147, 241, 206, 98, 43, 3, 104, 17, 40, 192, 79, 106, 162]; @@ -99,7 +92,7 @@ mod tests { #[test] fn test_seed_compute_after_newer() { - let seed_compute = SeedHashCompute::new(); + let seed_compute = SeedHashCompute::default(); // calculating an newer value first shouldn't affect the result let _ = seed_compute.hash_block_number(972764); let hash = [241, 175, 44, 134, 39, 121, 245, 239, 228, 236, 43, 160, 195, 152, 46, 7, 199, 5, 253, 147, 241, 206, 98, 43, 3, 104, 17, 40, 192, 79, 106, 162]; diff --git a/ethcore/src/cache_manager.rs b/ethcore/src/cache_manager.rs index 4199cb1d593..07a9750a0ee 100644 --- a/ethcore/src/cache_manager.rs +++ b/ethcore/src/cache_manager.rs @@ -19,7 +19,7 @@ use std::hash::Hash; const COLLECTION_QUEUE_SIZE: usize = 8; -pub struct CacheManager where T: Eq + Hash { +pub struct CacheManager { pref_cache_size: usize, max_cache_size: usize, bytes_per_cache_entry: usize, diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index f375f3c2e88..37dc03dee28 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -163,7 +163,7 @@ impl TransactOptions { } /// Transaction executor. -pub struct Executive<'a, B: 'a + StateBackend> { +pub struct Executive<'a, B: 'a> { state: &'a mut State, info: &'a EnvInfo, machine: &'a Machine, diff --git a/ethcore/src/externalities.rs b/ethcore/src/externalities.rs index 65d130c3422..d315122d56a 100644 --- a/ethcore/src/externalities.rs +++ b/ethcore/src/externalities.rs @@ -63,9 +63,7 @@ impl OriginInfo { } /// Implementation of evm Externalities. -pub struct Externalities<'a, T: 'a, V: 'a, B: 'a> - where T: Tracer, V: VMTracer, B: StateBackend -{ +pub struct Externalities<'a, T: 'a, V: 'a, B: 'a> { state: &'a mut State, env_info: &'a EnvInfo, machine: &'a Machine, diff --git a/ethcore/src/miner/stratum.rs b/ethcore/src/miner/stratum.rs index 26fb3eae6c9..ca74432790f 100644 --- a/ethcore/src/miner/stratum.rs +++ b/ethcore/src/miner/stratum.rs @@ -158,7 +158,7 @@ impl StratumJobDispatcher { /// New stratum job dispatcher given the miner and client fn new(miner: Weak, client: Weak) -> StratumJobDispatcher { StratumJobDispatcher { - seed_compute: Mutex::new(SeedHashCompute::new()), + seed_compute: Mutex::new(SeedHashCompute::default()), client: client, miner: miner, } diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index f785e24a335..0da61425442 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -305,7 +305,7 @@ pub fn prove_transaction + Send + Sync>( /// checkpoint can be discarded with `discard_checkpoint`. All of the orignal /// backed-up values are moved into a parent checkpoint (if any). /// -pub struct State { +pub struct State { db: B, root: H256, cache: RefCell>, diff --git a/ethcore/types/src/account_diff.rs b/ethcore/types/src/account_diff.rs index 521ed8ab1f8..9633ffeb078 100644 --- a/ethcore/types/src/account_diff.rs +++ b/ethcore/types/src/account_diff.rs @@ -24,7 +24,7 @@ use bytes::Bytes; #[derive(Debug, PartialEq, Eq, Clone)] /// Diff type for specifying a change (or not). -pub enum Diff where T: Eq { +pub enum Diff { /// Both sides are the same. Same, /// Left (pre, source) side doesn't include value, right side (post, destination) does. @@ -35,9 +35,15 @@ pub enum Diff where T: Eq { Died(T), } -impl Diff where T: Eq { +impl Diff { /// Construct new object with given `pre` and `post`. - pub fn new(pre: T, post: T) -> Self { if pre == post { Diff::Same } else { Diff::Changed(pre, post) } } + pub fn new(pre: T, post: T) -> Self where T: Eq { + if pre == post { + Diff::Same + } else { + Diff::Changed(pre, post) + } + } /// Get the before value, if there is one. pub fn pre(&self) -> Option<&T> { match *self { Diff::Died(ref x) | Diff::Changed(ref x, _) => Some(x), _ => None } } diff --git a/miner/src/pool/tests/mod.rs b/miner/src/pool/tests/mod.rs index a1a6ae46136..b5cbaab6319 100644 --- a/miner/src/pool/tests/mod.rs +++ b/miner/src/pool/tests/mod.rs @@ -984,7 +984,7 @@ fn should_avoid_reverifying_recently_rejected_transactions() { assert_eq!(txq.status().status.transaction_count, 0); } - +#[test] fn should_reject_early_in_case_gas_price_is_less_than_min_effective() { // given let txq = TransactionQueue::new( diff --git a/miner/src/work_notify.rs b/miner/src/work_notify.rs index 8825fd4b65f..efae26ff114 100644 --- a/miner/src/work_notify.rs +++ b/miner/src/work_notify.rs @@ -62,7 +62,7 @@ impl WorkPoster { client: fetch, remote: remote, urls: urls, - seed_compute: Mutex::new(SeedHashCompute::new()), + seed_compute: Mutex::new(SeedHashCompute::default()), } } } diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 1f94deb3895..b67c728e5d6 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -449,6 +449,17 @@ usage! { "--reserved-peers=[FILE]", "Provide a file containing enodes, one per line. These nodes will always have a reserved slot on top of the normal maximum peers.", + CHECK |args: &Args| { + if let (Some(max_peers), Some(min_peers)) = (args.arg_max_peers, args.arg_min_peers) { + if min_peers > max_peers { + return Err(ArgsError::PeerConfiguration); + } + } + + Ok(()) + }, + + ["API and Console Options – HTTP JSON-RPC"] FLAG flag_no_jsonrpc: (bool) = false, or |c: &Config| c.rpc.as_ref()?.disable.clone(), "--no-jsonrpc", @@ -879,57 +890,66 @@ usage! { "Target size of the whisper message pool in megabytes.", ["Legacy Options"] - FLAG flag_warp: (bool) = false, or |_| None, - "--warp", - "Does nothing; warp sync is enabled by default. Use --no-warp to disable.", - - FLAG flag_dapps_apis_all: (bool) = false, or |_| None, - "--dapps-apis-all", - "Dapps server is merged with HTTP JSON-RPC server. Use --jsonrpc-apis.", + // Options that are hidden from config, but are still unique for its functionality. FLAG flag_geth: (bool) = false, or |_| None, "--geth", "Run in Geth-compatibility mode. Sets the IPC path to be the same as Geth's. Overrides the --ipc-path and --ipcpath options. Alters RPCs to reflect Geth bugs. Includes the personal_ RPC by default.", - FLAG flag_testnet: (bool) = false, or |_| None, - "--testnet", - "Testnet mode. Equivalent to --chain testnet. Overrides the --keys-path option.", - FLAG flag_import_geth_keys: (bool) = false, or |_| None, "--import-geth-keys", "Attempt to import keys from Geth client.", - FLAG flag_ipcdisable: (bool) = false, or |_| None, - "--ipcdisable", - "Equivalent to --no-ipc.", - - FLAG flag_ipc_off: (bool) = false, or |_| None, - "--ipc-off", - "Equivalent to --no-ipc.", + // Options that either do nothing, or are replaced by other options. + // FLAG Removed in 1.6 or before. - FLAG flag_nodiscover: (bool) = false, or |_| None, - "--nodiscover", - "Equivalent to --no-discovery.", + FLAG flag_warp: (bool) = false, or |_| None, + "--warp", + "Does nothing; warp sync is enabled by default. Use --no-warp to disable.", FLAG flag_jsonrpc: (bool) = false, or |_| None, "-j, --jsonrpc", "Does nothing; HTTP JSON-RPC is on by default now.", + FLAG flag_rpc: (bool) = false, or |_| None, + "--rpc", + "Does nothing; HTTP JSON-RPC is on by default now.", + FLAG flag_jsonrpc_off: (bool) = false, or |_| None, "--jsonrpc-off", "Equivalent to --no-jsonrpc.", FLAG flag_webapp: (bool) = false, or |_| None, "-w, --webapp", - "Does nothing; dapps server is on by default now.", + "Does nothing; dapps server has been removed.", FLAG flag_dapps_off: (bool) = false, or |_| None, "--dapps-off", "Equivalent to --no-dapps.", - FLAG flag_rpc: (bool) = false, or |_| None, - "--rpc", - "Does nothing; HTTP JSON-RPC is on by default now.", + FLAG flag_ipcdisable: (bool) = false, or |_| None, + "--ipcdisable", + "Equivalent to --no-ipc.", + + FLAG flag_ipc_off: (bool) = false, or |_| None, + "--ipc-off", + "Equivalent to --no-ipc.", + + FLAG flag_testnet: (bool) = false, or |_| None, + "--testnet", + "Testnet mode. Equivalent to --chain testnet. Overrides the --keys-path option.", + + FLAG flag_nodiscover: (bool) = false, or |_| None, + "--nodiscover", + "Equivalent to --no-discovery.", + + // FLAG Removed in 1.7. + + FLAG flag_dapps_apis_all: (bool) = false, or |_| None, + "--dapps-apis-all", + "Dapps server is merged with HTTP JSON-RPC server. Use --jsonrpc-apis.", + + // FLAG Removed in 1.11. FLAG flag_public_node: (bool) = false, or |_| None, "--public-node", @@ -947,41 +967,15 @@ usage! { "--ui-no-validation", "Does nothing; UI is now a separate project.", - ARG arg_ui_interface: (String) = "local", or |_| None, - "--ui-interface=[IP]", - "Does nothing; UI is now a separate project.", - - ARG arg_ui_hosts: (String) = "none", or |_| None, - "--ui-hosts=[HOSTS]", - "Does nothing; UI is now a separate project.", - - ARG arg_ui_port: (u16) = 8180u16, or |_| None, - "--ui-port=[PORT]", - "Does nothing; UI is now a separate project.", - - ARG arg_dapps_port: (Option) = None, or |c: &Config| c.dapps.as_ref()?.port.clone(), - "--dapps-port=[PORT]", - "Dapps server is merged with HTTP JSON-RPC server. Use --jsonrpc-port.", - - ARG arg_dapps_interface: (Option) = None, or |c: &Config| c.dapps.as_ref()?.interface.clone(), - "--dapps-interface=[IP]", - "Dapps server is merged with HTTP JSON-RPC server. Use --jsonrpc-interface.", - - ARG arg_dapps_hosts: (Option) = None, or |c: &Config| c.dapps.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")), - "--dapps-hosts=[HOSTS]", - "Dapps server is merged with HTTP JSON-RPC server. Use --jsonrpc-hosts.", - - ARG arg_dapps_cors: (Option) = None, or |c: &Config| c.dapps.as_ref()?.cors.clone(), - "--dapps-cors=[URL]", - "Dapps server is merged with HTTP JSON-RPC server. Use --jsonrpc-cors.", + // ARG Removed in 1.6 or before. - ARG arg_dapps_user: (Option) = None, or |c: &Config| c.dapps.as_ref()?.user.clone(), - "--dapps-user=[USERNAME]", - "Dapps server authentication has been removed.", + ARG arg_etherbase: (Option) = None, or |_| None, + "--etherbase=[ADDRESS]", + "Equivalent to --author ADDRESS.", - ARG arg_dapps_pass: (Option) = None, or |c: &Config| c.dapps.as_ref()?.pass.clone(), - "--dapps-pass=[PASSWORD]", - "Dapps server authentication has been removed.", + ARG arg_extradata: (Option) = None, or |_| None, + "--extradata=[STRING]", + "Equivalent to --extra-data STRING.", ARG arg_datadir: (Option) = None, or |_| None, "--datadir=[PATH]", @@ -1027,23 +1021,55 @@ usage! { "--gasprice=[WEI]", "Equivalent to --min-gas-price WEI.", - ARG arg_etherbase: (Option) = None, or |_| None, - "--etherbase=[ADDRESS]", - "Equivalent to --author ADDRESS.", - - ARG arg_extradata: (Option) = None, or |_| None, - "--extradata=[STRING]", - "Equivalent to --extra-data STRING.", - ARG arg_cache: (Option) = None, or |_| None, "--cache=[MB]", "Equivalent to --cache-size MB.", - ARG arg_tx_queue_ban_count: (u16) = 1u16, or |c: &Config| c.mining.as_ref()?.tx_queue_ban_count.clone(), + // ARG Removed in 1.7. + + ARG arg_dapps_port: (Option) = None, or |c: &Config| c.dapps.as_ref()?.port.clone(), + "--dapps-port=[PORT]", + "Does nothing; dapps server has been removed.", + + ARG arg_dapps_interface: (Option) = None, or |c: &Config| c.dapps.as_ref()?.interface.clone(), + "--dapps-interface=[IP]", + "Does nothing; dapps server has been removed.", + + ARG arg_dapps_hosts: (Option) = None, or |c: &Config| c.dapps.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")), + "--dapps-hosts=[HOSTS]", + "Does nothing; dapps server has been removed.", + + ARG arg_dapps_cors: (Option) = None, or |c: &Config| c.dapps.as_ref()?.cors.clone(), + "--dapps-cors=[URL]", + "Does nothing; dapps server has been removed.", + + ARG arg_dapps_user: (Option) = None, or |c: &Config| c.dapps.as_ref()?.user.clone(), + "--dapps-user=[USERNAME]", + "Dapps server authentication has been removed.", + + ARG arg_dapps_pass: (Option) = None, or |c: &Config| c.dapps.as_ref()?.pass.clone(), + "--dapps-pass=[PASSWORD]", + "Dapps server authentication has been removed.", + + // ARG removed in 1.11. + + ARG arg_ui_interface: (Option) = None, or |_| None, + "--ui-interface=[IP]", + "Does nothing; UI is now a separate project.", + + ARG arg_ui_hosts: (Option) = None, or |_| None, + "--ui-hosts=[HOSTS]", + "Does nothing; UI is now a separate project.", + + ARG arg_ui_port: (Option) = None, or |_| None, + "--ui-port=[PORT]", + "Does nothing; UI is now a separate project.", + + ARG arg_tx_queue_ban_count: (Option) = None, or |c: &Config| c.mining.as_ref()?.tx_queue_ban_count.clone(), "--tx-queue-ban-count=[C]", "Not supported.", - ARG arg_tx_queue_ban_time: (u16) = 180u16, or |c: &Config| c.mining.as_ref()?.tx_queue_ban_time.clone(), + ARG arg_tx_queue_ban_time: (Option) = None, or |c: &Config| c.mining.as_ref()?.tx_queue_ban_time.clone(), "--tx-queue-ban-time=[SEC]", "Not supported.", } @@ -1427,11 +1453,11 @@ mod tests { let args = Args::parse(&["parity", "--password", "~/.safe/1", "--password", "~/.safe/2", "--ui-port", "8123"]).unwrap(); assert_eq!(args.arg_password, vec!["~/.safe/1".to_owned(), "~/.safe/2".to_owned()]); - assert_eq!(args.arg_ui_port, 8123); + assert_eq!(args.arg_ui_port, Some(8123)); let args = Args::parse(&["parity", "--password", "~/.safe/1,~/.safe/2", "--ui-port", "8123"]).unwrap(); assert_eq!(args.arg_password, vec!["~/.safe/1".to_owned(), "~/.safe/2".to_owned()]); - assert_eq!(args.arg_ui_port, 8123); + assert_eq!(args.arg_ui_port, Some(8123)); } #[test] @@ -1583,9 +1609,9 @@ mod tests { flag_force_ui: false, flag_no_ui: false, - arg_ui_port: 8180u16, - arg_ui_interface: "local".into(), - arg_ui_hosts: "none".into(), + arg_ui_port: None, + arg_ui_interface: None, + arg_ui_hosts: None, arg_ui_path: "$HOME/.parity/signer".into(), flag_ui_no_validation: false, @@ -1692,8 +1718,8 @@ mod tests { arg_tx_queue_mem_limit: 4u32, arg_tx_queue_gas: "off".into(), arg_tx_queue_strategy: "gas_factor".into(), - arg_tx_queue_ban_count: 1u16, - arg_tx_queue_ban_time: 180u16, + arg_tx_queue_ban_count: Some(1u16), + arg_tx_queue_ban_time: Some(180u16), flag_remove_solved: false, arg_notify_work: Some("http://localhost:3001".into()), flag_refuse_service_transactions: false, diff --git a/parity/cli/usage.rs b/parity/cli/usage.rs index 704aa5d6f1d..caacd364f2c 100644 --- a/parity/cli/usage.rs +++ b/parity/cli/usage.rs @@ -135,6 +135,9 @@ macro_rules! usage { $( ARG $arg:ident : ($($arg_type_tt:tt)+) = $arg_default:expr, or $arg_from_config:expr, $arg_usage:expr, $arg_help:expr, )* + $( + CHECK $check:expr, + )* )* } ) => { @@ -318,13 +321,6 @@ macro_rules! usage { pub fn parse>(command: &[S]) -> Result { let raw_args = RawArgs::parse(command)?; - if let (Some(max_peers), Some(min_peers)) = (raw_args.arg_max_peers, raw_args.arg_min_peers) { - // Invalid configuration pattern `mix_peers` > `max_peers` - if min_peers > max_peers { - return Err(ArgsError::PeerConfiguration); - } - } - // Skip loading config file if no_config flag is specified if raw_args.flag_no_config { return Ok(raw_args.into_args(Config::default())); @@ -332,7 +328,8 @@ macro_rules! usage { let config_file = raw_args.arg_config.clone().unwrap_or_else(|| raw_args.clone().into_args(Config::default()).arg_config); let config_file = replace_home(&::dir::default_data_path(), &config_file); - match (fs::File::open(&config_file), raw_args.arg_config.clone()) { + + let args = match (fs::File::open(&config_file), raw_args.arg_config.clone()) { // Load config file (Ok(mut file), _) => { println_stderr!("Loading config file from {}", &config_file); @@ -349,7 +346,15 @@ macro_rules! usage { Err(e) => Err(ArgsError::Config(config_file, e)) } }, - } + }?; + + $( + $( + $check(&args)?; + )* + )* + + Ok(args) } #[cfg(test)] diff --git a/parity/deprecated.rs b/parity/deprecated.rs index f3e433d1389..24bd1638b1a 100644 --- a/parity/deprecated.rs +++ b/parity/deprecated.rs @@ -37,6 +37,8 @@ impl fmt::Display for Deprecated { pub fn find_deprecated(args: &Args) -> Vec { let mut result = vec![]; + // Removed in 1.6 or before. + if args.flag_warp { result.push(Deprecated::DoesNothing("--warp")); } @@ -77,21 +79,78 @@ pub fn find_deprecated(args: &Args) -> Vec { result.push(Deprecated::Replaced("--extradata", "--extra-data")); } - // Removed in 1.7 + if args.flag_testnet { + result.push(Deprecated::Replaced("--testnet", "--chain testnet")); + } + + if args.flag_nodiscover { + result.push(Deprecated::Replaced("--nodiscover", "--no-discovery")); + } + + if args.arg_datadir.is_some() { + result.push(Deprecated::Replaced("--datadir", "--base-path")); + } + + if args.arg_networkid.is_some() { + result.push(Deprecated::Replaced("--networkid", "--network-id")); + } + + if args.arg_peers.is_some() { + result.push(Deprecated::Replaced("--peers", "--min-peers")); + } + + if args.arg_nodekey.is_some() { + result.push(Deprecated::Replaced("--nodekey", "--node-key")); + } + + if args.arg_rpcaddr.is_some() { + result.push(Deprecated::Replaced("--rpcaddr", "--jsonrpc-interface")); + } + + if args.arg_rpcport.is_some() { + result.push(Deprecated::Replaced("--rpcport", "--jsonrpc-port")); + } + + if args.arg_rpcapi.is_some() { + result.push(Deprecated::Replaced("--rpcapi", "--jsonrpc-api")); + } + + if args.arg_rpccorsdomain.is_some() { + result.push(Deprecated::Replaced("--rpccorsdomain", "--jsonrpc-cors")); + } + + if args.arg_ipcapi.is_some() { + result.push(Deprecated::Replaced("--ipcapi", "--ipc-apis")); + } + + if args.arg_ipcpath.is_some() { + result.push(Deprecated::Replaced("--ipcpath", "--ipc-path")); + } + + if args.arg_gasprice.is_some() { + result.push(Deprecated::Replaced("--gasprice", "--min-gas-price")); + } + + if args.arg_cache.is_some() { + result.push(Deprecated::Replaced("--cache", "--cache-size")); + } + + // Removed in 1.7. + if args.arg_dapps_port.is_some() { - result.push(Deprecated::Replaced("--dapps-port", "--jsonrpc-port")); + result.push(Deprecated::Removed("--dapps-port")); } if args.arg_dapps_interface.is_some() { - result.push(Deprecated::Replaced("--dapps-interface", "--jsonrpc-interface")); + result.push(Deprecated::Removed("--dapps-interface")); } if args.arg_dapps_hosts.is_some() { - result.push(Deprecated::Replaced("--dapps-hosts", "--jsonrpc-hosts")); + result.push(Deprecated::Removed("--dapps-hosts")); } if args.arg_dapps_cors.is_some() { - result.push(Deprecated::Replaced("--dapps-cors", "--jsonrpc-cors")); + result.push(Deprecated::Removed("--dapps-cors")); } if args.arg_dapps_user.is_some() { @@ -106,7 +165,43 @@ pub fn find_deprecated(args: &Args) -> Vec { result.push(Deprecated::Replaced("--dapps-apis-all", "--jsonrpc-apis")); } - // Removed in 1.8 + // Removed in 1.11. + + if args.flag_public_node { + result.push(Deprecated::Removed("--public-node")); + } + + if args.flag_force_ui { + result.push(Deprecated::Removed("--force-ui")); + } + + if args.flag_no_ui { + result.push(Deprecated::Removed("--no-ui")); + } + + if args.flag_ui_no_validation { + result.push(Deprecated::Removed("--ui-no-validation")); + } + + if args.arg_ui_interface.is_some() { + result.push(Deprecated::Removed("--ui-interface")); + } + + if args.arg_ui_hosts.is_some() { + result.push(Deprecated::Removed("--ui-hosts")); + } + + if args.arg_ui_port.is_some() { + result.push(Deprecated::Removed("--ui-port")); + } + + if args.arg_tx_queue_ban_count.is_some() { + result.push(Deprecated::Removed("--tx-queue-ban-count")); + } + + if args.arg_tx_queue_ban_time.is_some() { + result.push(Deprecated::Removed("--tx-queue-ban-time")); + } result } @@ -150,10 +245,10 @@ mod tests { Deprecated::Replaced("--ipc-off", "--no-ipc"), Deprecated::Replaced("--etherbase", "--author"), Deprecated::Replaced("--extradata", "--extra-data"), - Deprecated::Replaced("--dapps-port", "--jsonrpc-port"), - Deprecated::Replaced("--dapps-interface", "--jsonrpc-interface"), - Deprecated::Replaced("--dapps-hosts", "--jsonrpc-hosts"), - Deprecated::Replaced("--dapps-cors", "--jsonrpc-cors"), + Deprecated::Removed("--dapps-port"), + Deprecated::Removed("--dapps-interface"), + Deprecated::Removed("--dapps-hosts"), + Deprecated::Removed("--dapps-cors"), Deprecated::Removed("--dapps-user"), Deprecated::Removed("--dapps-pass"), Deprecated::Replaced("--dapps-apis-all", "--jsonrpc-apis"), diff --git a/parity/upgrade.rs b/parity/upgrade.rs index d98123ce13b..95fa8de823b 100644 --- a/parity/upgrade.rs +++ b/parity/upgrade.rs @@ -17,13 +17,12 @@ //! Parity upgrade logic use semver::{Version, SemVerError}; -use std::collections::*; +use std::collections::HashMap; use std::fs::{self, File, create_dir_all}; -use std::env; use std::io; use std::io::{Read, Write}; use std::path::{PathBuf, Path}; -use dir::{DatabaseDirectories, default_data_path}; +use dir::{DatabaseDirectories, default_data_path, home_dir}; use dir::helpers::replace_home; use journaldb::Algorithm; @@ -106,7 +105,7 @@ fn with_locked_version(db_path: Option<&str>, script: F) -> Result Result { let mut path = db_path.map_or({ - let mut path = env::home_dir().expect("Applications should have a home dir"); + let mut path = home_dir().expect("Applications should have a home dir"); path.push(".parity"); path }, PathBuf::from); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index bf781d76525..d20b2feb267 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -167,7 +167,7 @@ impl EthClient = (0..n).map(|i| public_values_generation(t, &derived_point, &polynoms1[i], &polynoms2[i]).unwrap()).collect(); // keys verification - (0..n).map(|i| (0..n).map(|j| if i != j { - assert!(keys_verification(t, &derived_point, &id_numbers[i], &secrets1[j][i], &secrets2[j][i], &publics[j]).unwrap()); - }).collect::>()).collect::>(); + (0..n).for_each(|i| { + (0..n) + .filter(|&j| i != j) + .for_each(|j| { + assert!(keys_verification(t, &derived_point, &id_numbers[i], &secrets1[j][i], &secrets2[j][i], &publics[j]).unwrap()); + }) + }); // data, generated during keys generation let public_shares: Vec<_> = (0..n).map(|i| compute_public_share(&polynoms1[i][0]).unwrap()).collect(); diff --git a/util/dir/Cargo.toml b/util/dir/Cargo.toml index e1a13401a25..bdaea99109e 100644 --- a/util/dir/Cargo.toml +++ b/util/dir/Cargo.toml @@ -1,9 +1,11 @@ [package] name = "dir" -version = "0.1.0" +version = "0.1.1" authors = ["Parity Technologies "] +license = "GPL3" [dependencies] ethereum-types = "0.3" journaldb = { path = "../journaldb" } app_dirs = { git = "https://github.com/paritytech/app-dirs-rs" } +dirs = "1.0.2" diff --git a/util/dir/src/helpers.rs b/util/dir/src/helpers.rs index 820b9dc5af6..8e703206b73 100644 --- a/util/dir/src/helpers.rs +++ b/util/dir/src/helpers.rs @@ -15,12 +15,11 @@ // along with Parity. If not, see . //! Directory helper functions -use std::env; /// Replaces `$HOME` str with home directory path. pub fn replace_home(base: &str, arg: &str) -> String { // the $HOME directory on mac os should be `~/Library` or `~/Library/Application Support` - let r = arg.replace("$HOME", env::home_dir().unwrap().to_str().unwrap()); + let r = arg.replace("$HOME", ::dirs::home_dir().unwrap().to_str().unwrap()); let r = r.replace("$BASE", base); r.replace("/", &::std::path::MAIN_SEPARATOR.to_string()) } diff --git a/util/dir/src/lib.rs b/util/dir/src/lib.rs index 7404a2cbcab..712b53f0de3 100644 --- a/util/dir/src/lib.rs +++ b/util/dir/src/lib.rs @@ -18,11 +18,12 @@ //! Dir utilities for platform-specific operations extern crate app_dirs; +extern crate dirs; extern crate ethereum_types; extern crate journaldb; pub mod helpers; -use std::{env, fs}; +use std::fs; use std::path::{PathBuf, Path}; use ethereum_types::{H64, H256}; use journaldb::Algorithm; @@ -31,19 +32,21 @@ use app_dirs::{AppInfo, get_app_root, AppDataType}; // re-export platform-specific functions use platform::*; +pub use dirs::home_dir; + /// Platform-specific chains path - Windows only -#[cfg(target_os = "windows")] pub const CHAINS_PATH: &'static str = "$LOCAL/chains"; +#[cfg(target_os = "windows")] pub const CHAINS_PATH: &str = "$LOCAL/chains"; /// Platform-specific chains path -#[cfg(not(target_os = "windows"))] pub const CHAINS_PATH: &'static str = "$BASE/chains"; +#[cfg(not(target_os = "windows"))] pub const CHAINS_PATH: &str = "$BASE/chains"; /// Platform-specific cache path - Windows only -#[cfg(target_os = "windows")] pub const CACHE_PATH: &'static str = "$LOCAL/cache"; +#[cfg(target_os = "windows")] pub const CACHE_PATH: &str = "$LOCAL/cache"; /// Platform-specific cache path -#[cfg(not(target_os = "windows"))] pub const CACHE_PATH: &'static str = "$BASE/cache"; +#[cfg(not(target_os = "windows"))] pub const CACHE_PATH: &str = "$BASE/cache"; // this const is irrelevent cause we do have migrations now, // but we still use it for backwards compatibility -const LEGACY_CLIENT_DB_VER_STR: &'static str = "5.3"; +const LEGACY_CLIENT_DB_VER_STR: &str = "5.3"; #[derive(Debug, PartialEq)] /// Parity local data directories @@ -239,7 +242,7 @@ pub fn default_hypervisor_path() -> PathBuf { /// Get home directory. fn home() -> PathBuf { - env::home_dir().expect("Failed to get home dir") + dirs::home_dir().expect("Failed to get home dir") } /// Geth path @@ -312,9 +315,9 @@ mod platform { #[cfg(not(any(target_os = "macos", windows)))] mod platform { use std::path::PathBuf; - pub const AUTHOR: &'static str = "parity"; - pub const PRODUCT: &'static str = "io.parity.ethereum"; - pub const PRODUCT_HYPERVISOR: &'static str = "io.parity.ethereum-updates"; + pub const AUTHOR: &str = "parity"; + pub const PRODUCT: &str = "io.parity.ethereum"; + pub const PRODUCT_HYPERVISOR: &str = "io.parity.ethereum-updates"; pub fn parity_base() -> PathBuf { let mut home = super::home(); diff --git a/util/path/Cargo.toml b/util/path/Cargo.toml index 7df3917b140..6d01d6488f3 100644 --- a/util/path/Cargo.toml +++ b/util/path/Cargo.toml @@ -1,6 +1,8 @@ [package] name = "path" -version = "0.1.0" -authors = ["debris "] +version = "0.1.1" +authors = ["Parity Technologies "] +license = "GPL3" [dependencies] +dirs = "1.0.2" diff --git a/util/path/src/lib.rs b/util/path/src/lib.rs index 38608db6604..3169274ad83 100644 --- a/util/path/src/lib.rs +++ b/util/path/src/lib.rs @@ -15,6 +15,8 @@ // along with Parity. If not, see . //! Path utilities +extern crate dirs; + use std::path::Path; use std::path::PathBuf; @@ -22,7 +24,7 @@ use std::path::PathBuf; /// Get the config path for application `name`. /// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`. pub fn config_path(name: &str) -> PathBuf { - let mut home = ::std::env::home_dir().expect("Failed to get home dir"); + let mut home = dirs::home_dir().expect("Failed to get home dir"); home.push("Library"); home.push(name); home @@ -32,7 +34,7 @@ pub fn config_path(name: &str) -> PathBuf { /// Get the config path for application `name`. /// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`. pub fn config_path(name: &str) -> PathBuf { - let mut home = ::std::env::home_dir().expect("Failed to get home dir"); + let mut home = dirs::home_dir().expect("Failed to get home dir"); home.push("AppData"); home.push("Roaming"); home.push(name); @@ -43,7 +45,7 @@ pub fn config_path(name: &str) -> PathBuf { /// Get the config path for application `name`. /// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`. pub fn config_path(name: &str) -> PathBuf { - let mut home = ::std::env::home_dir().expect("Failed to get home dir"); + let mut home = dirs::home_dir().expect("Failed to get home dir"); home.push(format!(".{}", name.to_lowercase())); home } diff --git a/util/triehash-ethereum/src/lib.rs b/util/triehash-ethereum/src/lib.rs index b7eed45ee39..7de77473c5b 100644 --- a/util/triehash-ethereum/src/lib.rs +++ b/util/triehash-ethereum/src/lib.rs @@ -24,32 +24,32 @@ use ethereum_types::H256; use keccak_hasher::KeccakHasher; /// Generates a trie root hash for a vector of key-value tuples -pub fn trie_root(input: I) -> H256 +pub fn trie_root(input: I) -> H256 where - I: IntoIterator, - A: AsRef<[u8]> + Ord, - B: AsRef<[u8]>, + I: IntoIterator, + K: AsRef<[u8]> + Ord, + V: AsRef<[u8]>, { triehash::trie_root::(input) } /// Generates a key-hashed (secure) trie root hash for a vector of key-value tuples. -pub fn sec_trie_root(input: I) -> H256 +pub fn sec_trie_root(input: I) -> H256 where - I: IntoIterator, - A: AsRef<[u8]>, - B: AsRef<[u8]>, + I: IntoIterator, + K: AsRef<[u8]>, + V: AsRef<[u8]>, { triehash::sec_trie_root::(input) } /// Generates a trie root hash for a vector of values -pub fn ordered_trie_root(input: I) -> H256 +pub fn ordered_trie_root(input: I) -> H256 where - I: IntoIterator, - A: AsRef<[u8]>, + I: IntoIterator, + V: AsRef<[u8]>, { - triehash::ordered_trie_root::(input) + triehash::ordered_trie_root::(input) } #[cfg(test)]