From b12d5920b2cbb369fea10492b91eab45c0ee99aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 13 Jul 2018 10:22:59 +0200 Subject: [PATCH] Make sure to produce full blocks. --- Cargo.toml | 1 + ethcore/Cargo.toml | 4 ++++ ethcore/src/ethereum/ethash.rs | 7 +++++++ ethcore/src/miner/miner.rs | 4 ++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ca90e9f6d90..93f84db582d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,6 +100,7 @@ ui-precompiled = [ ] ui-enabled = ["dapps"] dapps = ["parity-dapps"] +miner-debug = ["ethcore/miner-debug"] json-tests = ["ethcore/json-tests"] test-heavy = ["ethcore/test-heavy"] evm-debug = ["ethcore/evm-debug"] diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index c9db7cf9f68..bb0db865dbc 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -74,6 +74,10 @@ trie-standardmap = { path = "../util/trie-standardmap" } kvdb-rocksdb = { path = "../util/kvdb-rocksdb" } [features] +# Disables seal verification for mined blocks. +# This allows you to submit any seal via RPC to test and benchmark +# how fast pending block get's created while running on the mainnet. +miner-debug = [] # Display EVM debug traces. evm-debug = ["slow-blocks"] # Display EVM debug traces when running tests. diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index 09e9caf727b..50e02172dea 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -289,11 +289,18 @@ impl Engine for Arc { self.machine.note_rewards(block, &[(author, result_block_reward)], &uncle_rewards) } + #[cfg(not(feature = "miner-debug"))] fn verify_local_seal(&self, header: &Header) -> Result<(), Error> { self.verify_block_basic(header) .and_then(|_| self.verify_block_unordered(header)) } + #[cfg(feature = "miner-debug")] + fn verify_local_seal(&self, _header: &Header) -> Result<(), Error> { + warn!("Skipping seal verification, running in miner testing mode."); + Ok(()) + } + fn verify_block_basic(&self, header: &Header) -> Result<(), Error> { // check the seal fields. let seal = Seal::parse_seal(header.seal())?; diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index f0ed74f52b8..cb6275b74d4 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -95,7 +95,7 @@ const DEFAULT_MINIMAL_GAS_PRICE: u64 = 20_000_000_000; /// before stopping attempts to push more transactions to the block. /// This is an optimization that prevents traversing the entire pool /// in case we have only a fraction of available block gas limit left. -const MAX_SKIPPED_TRANSACTIONS: usize = 8; +const MAX_SKIPPED_TRANSACTIONS: usize = 128; /// Configures the behaviour of the miner. #[derive(Debug, PartialEq)] @@ -391,7 +391,7 @@ impl Miner { let max_transactions = if min_tx_gas.is_zero() { usize::max_value() } else { - (*open_block.block().header().gas_limit() / min_tx_gas).as_u64() as usize + MAX_SKIPPED_TRANSACTIONS.saturating_add((*open_block.block().header().gas_limit() / min_tx_gas).as_u64() as usize) }; let pending: Vec> = self.transaction_queue.pending(