[ethcore cleanup]: various unrelated fixes from #11493 (#11507)
* [cleanup]: various unrelated fixes from `#11493` * [revert]: too verbose logging `seal` * fix nit: don't mix from() and into()
This commit is contained in:
@@ -102,7 +102,7 @@ pub trait Drain {
|
||||
|
||||
impl<'x> OpenBlock<'x> {
|
||||
/// Create a new `OpenBlock` ready for transaction pushing.
|
||||
pub fn new<'a>(
|
||||
pub fn new(
|
||||
engine: &'x dyn Engine,
|
||||
factories: Factories,
|
||||
tracing: bool,
|
||||
@@ -204,12 +204,11 @@ impl<'x> OpenBlock<'x> {
|
||||
let hash = t.hash();
|
||||
let start = time::Instant::now();
|
||||
self.push_transaction(t)?;
|
||||
let took = start.elapsed();
|
||||
let took_ms = took.as_secs() * 1000 + took.subsec_nanos() as u64 / 1000000;
|
||||
if took > time::Duration::from_millis(slow_tx) {
|
||||
warn!("Heavy ({} ms) transaction in block {:?}: {:?}", took_ms, self.block.header.number(), hash);
|
||||
let elapsed_millis = start.elapsed().as_millis();
|
||||
if elapsed_millis > slow_tx {
|
||||
warn!("Heavy ({} ms) transaction in block {:?}: {:?}", elapsed_millis, self.block.header.number(), hash);
|
||||
}
|
||||
debug!(target: "tx", "Transaction {:?} took: {} ms", hash, took_ms);
|
||||
debug!(target: "tx", "Transaction {:?} took: {} ms", hash, elapsed_millis);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -347,10 +346,10 @@ impl LockedBlock {
|
||||
let expected_seal_fields = engine.seal_fields(&self.header);
|
||||
let mut s = self;
|
||||
if seal.len() != expected_seal_fields {
|
||||
Err(BlockError::InvalidSealArity(Mismatch {
|
||||
return Err(Error::Block(BlockError::InvalidSealArity(Mismatch {
|
||||
expected: expected_seal_fields,
|
||||
found: seal.len()
|
||||
}))?;
|
||||
})));
|
||||
}
|
||||
|
||||
s.block.header.set_seal(seal);
|
||||
@@ -504,7 +503,6 @@ mod tests {
|
||||
verification::Unverified,
|
||||
};
|
||||
use hash_db::EMPTY_PREFIX;
|
||||
use spec;
|
||||
|
||||
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
|
||||
fn enact_bytes(
|
||||
|
||||
@@ -2388,7 +2388,7 @@ impl ImportSealedBlock for Client {
|
||||
// Do a super duper basic verification to detect potential bugs
|
||||
if let Err(e) = self.engine.verify_block_basic(&header) {
|
||||
self.importer.bad_blocks.report(
|
||||
block.rlp_bytes(),
|
||||
raw,
|
||||
format!("Detected an issue with locally sealed block: {}", e),
|
||||
);
|
||||
return Err(e);
|
||||
|
||||
@@ -716,36 +716,34 @@ impl Miner {
|
||||
},
|
||||
};
|
||||
|
||||
let sealing_result =
|
||||
match self.engine.generate_seal(&block, &parent_header) {
|
||||
// Directly import a regular sealed block.
|
||||
Seal::Regular(seal) => {
|
||||
trace!(target: "miner", "Block #{}: Received a Regular seal.", block_number);
|
||||
{
|
||||
let mut sealing = self.sealing.lock();
|
||||
sealing.next_mandatory_reseal = Instant::now() + self.options.reseal_max_period;
|
||||
}
|
||||
match self.engine.generate_seal(&block, &parent_header) {
|
||||
// Directly import a regular sealed block.
|
||||
Seal::Regular(seal) => {
|
||||
trace!(target: "miner", "Block #{}: Received a Regular seal.", block_number);
|
||||
{
|
||||
let mut sealing = self.sealing.lock();
|
||||
sealing.next_mandatory_reseal = Instant::now() + self.options.reseal_max_period;
|
||||
}
|
||||
|
||||
block
|
||||
.lock()
|
||||
.seal(&*self.engine, seal)
|
||||
.map(|sealed| {
|
||||
match chain.import_sealed_block(sealed) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
error!(target: "miner", "Block #{}: seal_and_import_block_internally: import_sealed_block returned {:?}", block_number, e);
|
||||
false
|
||||
}
|
||||
block
|
||||
.lock()
|
||||
.seal(&*self.engine, seal)
|
||||
.map(|sealed| {
|
||||
match chain.import_sealed_block(sealed) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
error!(target: "miner", "Block #{}: seal_and_import_block_internally: import_sealed_block returned {:?}", block_number, e);
|
||||
false
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|e| {
|
||||
warn!("ERROR: Block #{}, importing sealed block failed when given internally generated seal: {}", block_number, e);
|
||||
false
|
||||
})
|
||||
},
|
||||
Seal::None => false,
|
||||
};
|
||||
sealing_result
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|e| {
|
||||
warn!("ERROR: Block #{}, importing sealed block failed when given internally generated seal: {}", block_number, e);
|
||||
false
|
||||
})
|
||||
},
|
||||
Seal::None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Prepares work which has to be done to seal.
|
||||
@@ -1276,7 +1274,6 @@ impl miner::MinerService for Miner {
|
||||
if self.seal_and_import_block_internally(chain, block) {
|
||||
trace!(target: "miner", "update_sealing: imported internally sealed block");
|
||||
}
|
||||
return
|
||||
},
|
||||
SealingState::NotReady => unreachable!("We returned right after sealing_state was computed. qed."),
|
||||
SealingState::External => {
|
||||
|
||||
Reference in New Issue
Block a user