From 1f176c7798d4b8a677c056bbfff353370c9ef4a6 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Fri, 14 Jul 2017 17:42:36 +0200 Subject: [PATCH] Backporting to stable (#6060) * --reseal-on-uncle (#5940) * --reseal-on-uncle * Optimized uncle check * Additional uncle check * Updated comment * v1.6.9 * CLI: Export error message and less verbose peer counter. (#5870) * Removed numbed of active connections from informant * Print error message when fatdb is required * Remove peers from UI --- Cargo.lock | 50 +++++++++++------------ Cargo.toml | 2 +- ethcore/src/client/client.rs | 27 ++++++++++++ ethcore/src/client/test_client.rs | 6 ++- ethcore/src/client/traits.rs | 5 ++- ethcore/src/error.rs | 3 ++ ethcore/src/miner/miner.rs | 14 ++++--- ethcore/src/verification/verification.rs | 11 +++++ js/src/views/Application/Status/status.js | 2 +- mac/Parity.pkgproj | 2 +- mac/Parity/Info.plist | 2 +- nsis/installer.nsi | 2 +- parity/blockchain.rs | 12 ++++-- parity/cli/mod.rs | 5 +++ parity/cli/usage.txt | 3 ++ parity/configuration.rs | 1 + parity/informant.rs | 3 +- rpc/src/v1/tests/eth.rs | 1 + util/Cargo.toml | 2 +- 19 files changed, 109 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a246b2ba512..2ecef74b2a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "parity" -version = "1.6.8" +version = "1.6.9" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "app_dirs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -23,7 +23,7 @@ dependencies = [ "ethcore-secretstore 1.0.0", "ethcore-signer 1.6.0", "ethcore-stratum 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethsync 1.6.0", "evmbin 0.1.0", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -394,7 +394,7 @@ dependencies = [ "ethcore-ipc-codegen 1.6.0", "ethcore-ipc-nano 1.6.0", "ethcore-stratum 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethjson 0.1.0", "ethkey 0.2.0", "ethstore 0.1.0", @@ -444,7 +444,7 @@ dependencies = [ "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.6.0", "ethcore-rpc 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "fetch 0.1.0", "futures 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.0-a.0 (git+https://github.com/ethcore/hyper)", @@ -492,7 +492,7 @@ name = "ethcore-ipc" version = "1.6.0" dependencies = [ "ethcore-devtools 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "nanomsg 0.5.1 (git+https://github.com/paritytech/nanomsg.rs.git?branch=parity-1.7)", "semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -539,7 +539,7 @@ dependencies = [ "ethcore-ipc 1.6.0", "ethcore-ipc-codegen 1.6.0", "ethcore-ipc-nano 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "nanomsg 0.5.1 (git+https://github.com/paritytech/nanomsg.rs.git?branch=parity-1.7)", "semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -554,7 +554,7 @@ dependencies = [ "ethcore-ipc 1.6.0", "ethcore-ipc-codegen 1.6.0", "ethcore-network 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "futures 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -570,7 +570,7 @@ name = "ethcore-logger" version = "1.6.0" dependencies = [ "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "isatty 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -586,7 +586,7 @@ dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.6.0", "ethcore-io 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethcrypto 0.1.0", "ethkey 0.2.0", "igd 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -614,7 +614,7 @@ dependencies = [ "ethcore-io 1.6.0", "ethcore-ipc 1.6.0", "ethcore-light 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethcrypto 0.1.0", "ethjson 0.1.0", "ethkey 0.2.0", @@ -649,7 +649,7 @@ dependencies = [ "ethcore-ipc 1.6.0", "ethcore-ipc-codegen 1.6.0", "ethcore-ipc-nano 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethcrypto 0.1.0", "ethkey 0.2.0", "hyper 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -667,7 +667,7 @@ dependencies = [ "ethcore-devtools 1.6.0", "ethcore-io 1.6.0", "ethcore-rpc 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "jsonrpc-core 6.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.6)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -686,7 +686,7 @@ dependencies = [ "ethcore-ipc 1.6.0", "ethcore-ipc-codegen 1.6.0", "ethcore-ipc-nano 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "futures 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 6.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.6)", "jsonrpc-macros 6.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.6)", @@ -700,7 +700,7 @@ dependencies = [ [[package]] name = "ethcore-util" -version = "1.6.8" +version = "1.6.9" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -749,7 +749,7 @@ dependencies = [ name = "ethjson" version = "0.1.0" dependencies = [ - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -777,7 +777,7 @@ version = "0.1.0" dependencies = [ "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethcrypto 0.1.0", "ethkey 0.2.0", "itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -810,7 +810,7 @@ dependencies = [ "ethcore-ipc-nano 1.6.0", "ethcore-light 1.6.0", "ethcore-network 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethkey 0.2.0", "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -828,7 +828,7 @@ version = "0.1.0" dependencies = [ "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1084,7 +1084,7 @@ version = "1.6.0" dependencies = [ "ethcore-ipc 1.6.0", "ethcore-ipc-codegen 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1687,7 +1687,7 @@ name = "parity-hash-fetch" version = "1.6.0" dependencies = [ "ethabi 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "fetch 0.1.0", "futures 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1704,7 +1704,7 @@ version = "1.6.0" dependencies = [ "cid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "hyper 0.10.0-a.0 (git+https://github.com/ethcore/hyper)", "jsonrpc-http-server 6.0.0 (git+https://github.com/ethcore/jsonrpc.git?branch=parity-1.6)", "mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1718,7 +1718,7 @@ version = "0.1.0" dependencies = [ "ethcore 1.6.0", "ethcore-io 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethkey 0.2.0", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.1.0", @@ -1741,7 +1741,7 @@ version = "1.4.0" dependencies = [ "ethcore-rpc 1.6.0", "ethcore-signer 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "futures 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 6.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.6)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1785,7 +1785,7 @@ dependencies = [ "ethcore 1.6.0", "ethcore-ipc 1.6.0", "ethcore-ipc-codegen 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "ethsync 1.6.0", "ipc-common-types 1.6.0", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2084,7 +2084,7 @@ version = "1.4.0" dependencies = [ "ethcore-bigint 0.1.2", "ethcore-rpc 1.6.0", - "ethcore-util 1.6.8", + "ethcore-util 1.6.9", "futures 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-rpc-client 1.4.0", "rpassword 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index e7443069037..a6fa9be3232 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Parity Ethereum client" name = "parity" -version = "1.6.8" +version = "1.6.9" license = "GPL-3.0" authors = ["Parity Technologies "] diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 3a33fe47c18..2025e2bda34 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1532,6 +1532,33 @@ impl MiningBlockChainClient for Client { open_block } + fn reopen_block(&self, block: ClosedBlock) -> OpenBlock { + let engine = &*self.engine; + let mut block = block.reopen(engine); + let max_uncles = engine.maximum_uncle_count(); + if block.uncles().len() < max_uncles { + let chain = self.chain.read(); + let h = chain.best_block_hash(); + // Add new uncles + let uncles = chain + .find_uncle_hashes(&h, engine.maximum_uncle_age()) + .unwrap_or_else(Vec::new); + + for h in uncles { + if !block.uncles().iter().any(|header| header.hash() == h) { + let uncle = chain.block_header(&h).expect("find_uncle_hashes only returns hashes for existing headers; qed"); + block.push_uncle(uncle).expect("pushing up to maximum_uncle_count; + push_uncle is not ok only if more than maximum_uncle_count is pushed; + so all push_uncle are Ok; + qed"); + if block.uncles().len() >= max_uncles { break } + } + } + + } + block + } + fn vm_factory(&self) -> &EvmFactory { &self.factories.vm } diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 3898f73b7b1..3a1940ac869 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -42,7 +42,7 @@ use types::mode::Mode; use types::pruning_info::PruningInfo; use verification::queue::QueueInfo; -use block::{OpenBlock, SealedBlock}; +use block::{OpenBlock, SealedBlock, ClosedBlock}; use executive::Executed; use error::CallError; use trace::LocalizedTrace; @@ -378,6 +378,10 @@ impl MiningBlockChainClient for TestBlockChainClient { open_block } + fn reopen_block(&self, block: ClosedBlock) -> OpenBlock { + block.reopen(&*self.spec.engine) + } + fn vm_factory(&self) -> &EvmFactory { &self.vm_factory } diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index 6d5e87b4ba0..4d3bf1a7c61 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -18,7 +18,7 @@ use std::collections::BTreeMap; use util::{U256, Address, H256, H2048, Bytes, Itertools}; use blockchain::TreeRoute; use verification::queue::QueueInfo as BlockQueueInfo; -use block::{OpenBlock, SealedBlock}; +use block::{OpenBlock, SealedBlock, ClosedBlock}; use header::{BlockNumber}; use transaction::{LocalizedTransaction, PendingTransaction, SignedTransaction}; use transaction_import::TransactionImportResult; @@ -277,6 +277,9 @@ pub trait MiningBlockChainClient: BlockChainClient { extra_data: Bytes ) -> OpenBlock; + /// Reopens an OpenBlock and updates uncles. + fn reopen_block(&self, block: ClosedBlock) -> OpenBlock; + /// Returns EvmFactory. fn vm_factory(&self) -> &EvmFactory; diff --git a/ethcore/src/error.rs b/ethcore/src/error.rs index 984df79bc42..e847711d023 100644 --- a/ethcore/src/error.rs +++ b/ethcore/src/error.rs @@ -129,6 +129,8 @@ pub enum BlockError { UncleIsBrother(OutOfBounds), /// An uncle is already in the chain. UncleInChain(H256), + /// An uncle is included twice. + DuplicateUncle(H256), /// An uncle has a parent not in the chain. UncleParentNotInChain(H256), /// State root header field is invalid. @@ -184,6 +186,7 @@ impl fmt::Display for BlockError { UncleTooOld(ref oob) => format!("Uncle block is too old. {}", oob), UncleIsBrother(ref oob) => format!("Uncle from same generation as block. {}", oob), UncleInChain(ref hash) => format!("Uncle {} already in chain", hash), + DuplicateUncle(ref hash) => format!("Uncle {} already in the header", hash), UncleParentNotInChain(ref hash) => format!("Uncle {} has a parent not in the chain", hash), InvalidStateRoot(ref mis) => format!("Invalid state root in header: {}", mis), InvalidGasUsed(ref mis) => format!("Invalid gas used in header: {}", mis), diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index c8f47029b1a..d380f0b2db5 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -88,6 +88,8 @@ pub struct MinerOptions { pub reseal_on_external_tx: bool, /// Reseal on receipt of new local transactions. pub reseal_on_own_tx: bool, + /// Reseal when new uncle block has been imported. + pub reseal_on_uncle: bool, /// Minimum period between transaction-inspired reseals. pub reseal_min_period: Duration, /// Maximum amount of gas to bother considering for block insertion. @@ -117,6 +119,7 @@ impl Default for MinerOptions { force_sealing: false, reseal_on_external_tx: false, reseal_on_own_tx: true, + reseal_on_uncle: false, tx_gas_limit: !U256::zero(), tx_queue_size: 1024, tx_queue_gas_limit: GasLimit::Auto, @@ -339,7 +342,7 @@ impl Miner { Some(old_block) => { trace!(target: "miner", "prepare_block: Already have previous work; updating and returning"); // add transactions to old_block - old_block.reopen(&*self.engine) + chain.reopen_block(old_block) } None => { // block not found - create it. @@ -358,7 +361,6 @@ impl Miner { let mut transactions_to_penalize = HashSet::new(); let block_number = open_block.block().fields().header.number(); - // TODO Push new uncles too. let mut tx_count: usize = 0; let tx_total = transactions.len(); for tx in transactions { @@ -1142,11 +1144,10 @@ impl MinerService for Miner { }) } - fn chain_new_blocks(&self, chain: &MiningBlockChainClient, _imported: &[H256], _invalid: &[H256], enacted: &[H256], retracted: &[H256]) { + fn chain_new_blocks(&self, chain: &MiningBlockChainClient, imported: &[H256], _invalid: &[H256], enacted: &[H256], retracted: &[H256]) { trace!(target: "miner", "chain_new_blocks"); - // 1. We ignore blocks that were `imported` (because it means that they are not in canon-chain, and transactions - // should be still available in the queue. + // 1. We ignore blocks that were `imported` unless resealing on new uncles is enabled. // 2. We ignore blocks that are `invalid` because it doesn't have any meaning in terms of the transactions that // are in those blocks @@ -1181,7 +1182,7 @@ impl MinerService for Miner { transaction_queue.remove_old(&fetch_account, time); } - if enacted.len() > 0 { + if enacted.len() > 0 || (imported.len() > 0 && self.options.reseal_on_uncle) { // -------------------------------------------------------------------------- // | NOTE Code below requires transaction_queue and sealing_work locks. | // | Make sure to release the locks before calling that method. | @@ -1300,6 +1301,7 @@ mod tests { force_sealing: false, reseal_on_external_tx: false, reseal_on_own_tx: true, + reseal_on_uncle: false, reseal_min_period: Duration::from_secs(5), tx_gas_limit: !U256::zero(), tx_queue_size: 1024, diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 34a4ccbd00a..dd266ee9b2e 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -124,12 +124,17 @@ pub fn verify_block_family(header: &Header, bytes: &[u8], engine: &Engine, bc: & } } + let mut verified = HashSet::new(); for uncle in UntrustedRlp::new(bytes).at(2)?.iter().map(|rlp| rlp.as_val::
()) { let uncle = uncle?; if excluded.contains(&uncle.hash()) { return Err(From::from(BlockError::UncleInChain(uncle.hash()))) } + if verified.contains(&uncle.hash()) { + return Err(From::from(BlockError::DuplicateUncle(uncle.hash()))) + } + // m_currentBlock.number() - uncle.number() m_cB.n - uP.n() // 1 2 // 2 @@ -172,6 +177,7 @@ pub fn verify_block_family(header: &Header, bytes: &[u8], engine: &Engine, bc: & verify_parent(&uncle, &uncle_parent)?; engine.verify_block_family(&uncle, &uncle_parent, Some(bytes))?; + verified.insert(uncle.hash()); } } Ok(()) @@ -555,6 +561,11 @@ mod tests { check_fail(family_test(&create_test_block_with_data(&header, &good_transactions, &bad_uncles), engine, &bc), TooManyUncles(OutOfBounds { max: Some(engine.maximum_uncle_count()), min: None, found: bad_uncles.len() })); + header = good.clone(); + bad_uncles = vec![ good_uncle1.clone(), good_uncle1.clone() ]; + check_fail(family_test(&create_test_block_with_data(&header, &good_transactions, &bad_uncles), engine, &bc), + DuplicateUncle(good_uncle1.hash())); + // TODO: some additional uncle checks } } diff --git a/js/src/views/Application/Status/status.js b/js/src/views/Application/Status/status.js index a9efcdb9327..a86543420ae 100644 --- a/js/src/views/Application/Status/status.js +++ b/js/src/views/Application/Status/status.js @@ -49,7 +49,7 @@ class Status extends Component { { netChain }
- { netPeers.active.toFormat() }/{ netPeers.connected.toFormat() }/{ netPeers.max.toFormat() } peers + { netPeers.connected.toFormat() }/{ netPeers.max.toFormat() } peers
diff --git a/mac/Parity.pkgproj b/mac/Parity.pkgproj index 9056db81598..03e2ec55e68 100755 --- a/mac/Parity.pkgproj +++ b/mac/Parity.pkgproj @@ -462,7 +462,7 @@ OVERWRITE_PERMISSIONS VERSION - 1.6.8 + 1.6.9 UUID 2DCD5B81-7BAF-4DA1-9251-6274B089FD36 diff --git a/mac/Parity/Info.plist b/mac/Parity/Info.plist index b2d3bf3157e..6e52b393fc0 100644 --- a/mac/Parity/Info.plist +++ b/mac/Parity/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.6.8 + 1.6.9 CFBundleVersion 1 LSApplicationCategoryType diff --git a/nsis/installer.nsi b/nsis/installer.nsi index 59bf9b2ef2b..622c99a8c51 100644 --- a/nsis/installer.nsi +++ b/nsis/installer.nsi @@ -10,7 +10,7 @@ !define DESCRIPTION "Fast, light, robust Ethereum implementation" !define VERSIONMAJOR 1 !define VERSIONMINOR 6 -!define VERSIONBUILD 8 +!define VERSIONBUILD 9 !define ARGS "--warp" !define FIRST_START_ARGS "ui --warp --mode=passive" diff --git a/parity/blockchain.rs b/parity/blockchain.rs index 1eeb3d71e97..092dd5073f3 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -319,7 +319,8 @@ fn start_client( fat_db: Switch, compaction: DatabaseCompactionProfile, wal: bool, - cache_config: CacheConfig + cache_config: CacheConfig, + require_fat_db: bool, ) -> Result { // load spec file @@ -347,6 +348,9 @@ fn start_client( // check if fatdb is on let fat_db = fatdb_switch_to_bool(fat_db, &user_defaults, algorithm)?; + if !fat_db && require_fat_db { + return Err("This command requires Parity to be synced with --fat-db on.".to_owned()); + } // prepare client and snapshot paths. let client_path = db_dirs.client_path(algorithm); @@ -399,7 +403,8 @@ fn execute_export(cmd: ExportBlockchain) -> Result<(), String> { cmd.fat_db, cmd.compaction, cmd.wal, - cmd.cache_config + cmd.cache_config, + false, )?; let panic_handler = PanicHandler::new_in_arc(); let format = cmd.format.unwrap_or_default(); @@ -442,7 +447,8 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> { cmd.fat_db, cmd.compaction, cmd.wal, - cmd.cache_config + cmd.cache_config, + true )?; let panic_handler = PanicHandler::new_in_arc(); diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index ac12137a2d6..d5763bc3c39 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -224,6 +224,8 @@ usage! { or |c: &Config| otry!(c.mining).force_sealing.clone(), flag_reseal_on_txs: String = "own", or |c: &Config| otry!(c.mining).reseal_on_txs.clone(), + flag_reseal_on_uncle: bool = false, + or |c: &Config| otry!(c.mining).reseal_on_uncle.clone(), flag_reseal_min_period: u64 = 2000u64, or |c: &Config| otry!(c.mining).reseal_min_period.clone(), flag_work_queue_size: usize = 20usize, @@ -461,6 +463,7 @@ struct Mining { author: Option, engine_signer: Option, force_sealing: Option, + reseal_on_uncle: Option, reseal_on_txs: Option, reseal_min_period: Option, work_queue_size: Option, @@ -705,6 +708,7 @@ mod tests { flag_force_sealing: true, flag_reseal_on_txs: "all".into(), flag_reseal_min_period: 4000u64, + flag_reseal_on_uncle: false, flag_work_queue_size: 20usize, flag_tx_gas_limit: Some("6283184".into()), flag_tx_time_limit: Some(100u64), @@ -904,6 +908,7 @@ mod tests { engine_signer: Some("0xdeadbeefcafe0000000000000000000000000001".into()), force_sealing: Some(true), reseal_on_txs: Some("all".into()), + reseal_on_uncle: None, reseal_min_period: Some(4000), work_queue_size: None, relay_set: None, diff --git a/parity/cli/usage.txt b/parity/cli/usage.txt index d3baeede1c2..63c06307844 100644 --- a/parity/cli/usage.txt +++ b/parity/cli/usage.txt @@ -221,6 +221,9 @@ Sealing/Mining Options: ext - reseal only on a new external transaction; all - reseal on all new transactions (default: {flag_reseal_on_txs}). + --reseal-on-uncle Force the node to author new blocks when a new uncle + block is imported. + (default: {flag_reseal_on_uncle}) --reseal-min-period MS Specify the minimum time between reseals from incoming transactions. MS is time measured in milliseconds (default: {flag_reseal_min_period}). diff --git a/parity/configuration.rs b/parity/configuration.rs index 866fb3a3a59..7bd3a8e6b5e 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -506,6 +506,7 @@ impl Configuration { force_sealing: self.args.flag_force_sealing, reseal_on_external_tx: reseal.external, reseal_on_own_tx: reseal.own, + reseal_on_uncle: self.args.flag_reseal_on_uncle, tx_gas_limit: match self.args.flag_tx_gas_limit { Some(ref d) => to_u256(d)?, None => U256::max_value(), diff --git a/parity/informant.rs b/parity/informant.rs index 2fa95db9afb..e1ba4e01e1d 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -159,7 +159,7 @@ impl Informant { false => String::new(), }, match (&sync_status, &network_config) { - (&Some(ref sync_info), &Some(ref net_config)) => format!("{}{}/{}/{} peers", + (&Some(ref sync_info), &Some(ref net_config)) => format!("{}{}/{} peers", match importing { true => format!("{} ", paint(Green.bold(), format!("{:>8}", format!("#{}", sync_info.last_imported_block_number.unwrap_or(chain_info.best_block_number))))), false => match sync_info.last_imported_old_block_number { @@ -167,7 +167,6 @@ impl Informant { None => String::new(), } }, - paint(Cyan.bold(), format!("{:2}", sync_info.num_active_peers)), paint(Cyan.bold(), format!("{:2}", sync_info.num_peers)), paint(Cyan.bold(), format!("{:2}", sync_info.current_max_peers(net_config.min_peers, net_config.max_peers))), ), diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index c505a2d5d1a..61ded500a82 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -57,6 +57,7 @@ fn miner_service(spec: &Spec, accounts: Arc) -> Arc { force_sealing: true, reseal_on_external_tx: true, reseal_on_own_tx: true, + reseal_on_uncle: false, tx_queue_size: 1024, tx_gas_limit: !U256::zero(), tx_queue_strategy: PrioritizationStrategy::GasPriceOnly, diff --git a/util/Cargo.toml b/util/Cargo.toml index 8370bfff2bf..7cba3675e8d 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -3,7 +3,7 @@ description = "Ethcore utility library" homepage = "http://parity.io" license = "GPL-3.0" name = "ethcore-util" -version = "1.6.8" +version = "1.6.9" authors = ["Parity Technologies "] build = "build.rs"