Improve logging and cleanup in miner around block sealing (#10745)

* Stop breaking out of loop if a non-canonical hash is found

* include expected hash in log msg

* More logging

* Scope

* Syntax

* Log in blank RollingFinality
Escalate bad proposer to warning

* Check validator set size: warn if 1 or even number

* More readable code

* Use SimpleList::new

* Extensive logging on unexpected non-canonical hash

* Wording

* wip

* Update ethcore/blockchain/src/blockchain.rs

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Improved logging, address grumbles

* Update ethcore/src/engines/validator_set/simple_list.rs

Co-Authored-By: Luke Schoen <ltfschoen@users.noreply.github.com>

* Report benign misbehaviour iff currently a validator

* Report malicious behaviour iff we're a validator

* Escalate to warning and fix wording

* Test reporting behaviour
Don't require node to be part of the validator set to report malicious behaviour

* Include missing parent hash in MissingParent error

* Update ethcore/src/engines/validator_set/simple_list.rs

Co-Authored-By: Luke Schoen <ltfschoen@users.noreply.github.com>

* docs

* remove unneeded into()
Move check for parent_step == step for clarity&efficiency
Remove dead code for Seal::Proposal

* typo

* Wording

* naming

* WIP

* cleanup

* cosmetics

* cosmetics and one less lvar

* spelling

* Better loggin when a block is already in chain

* More logging

* On second thought non-validators are allowed to report

* cleanup

* remove dead code

* Keep track of the hash of the last imported block

* Let it lock

* Serialize access to block sealing

* Take a lock while sealing a block

* Cleanup

* whitespace
This commit is contained in:
David
2019-07-04 18:03:22 +02:00
committed by GitHub
parent fafb534cd3
commit de906d4afd
13 changed files with 153 additions and 120 deletions

View File

@@ -473,7 +473,16 @@ impl Importer {
//
// The header passed is from the original block data and is sealed.
// TODO: should return an error if ImportRoute is none, issue #9910
fn commit_block<B>(&self, block: B, header: &Header, block_data: encoded::Block, pending: Option<PendingTransition>, client: &Client) -> ImportRoute where B: Drain {
fn commit_block<B>(
&self,
block: B,
header: &Header,
block_data: encoded::Block,
pending: Option<PendingTransition>,
client: &Client
) -> ImportRoute
where B: Drain
{
let hash = &header.hash();
let number = header.number();
let parent = header.parent_hash();
@@ -499,18 +508,17 @@ impl Importer {
};
let best = {
let hash = best_hash;
let header = chain.block_header_data(&hash)
let header = chain.block_header_data(&best_hash)
.expect("Best block is in the database; qed")
.decode()
.expect("Stored block header is valid RLP; qed");
let details = chain.block_details(&hash)
let details = chain.block_details(&best_hash)
.expect("Best block is in the database; qed");
ExtendedHeader {
parent_total_difficulty: details.total_difficulty - *header.difficulty(),
is_finalized: details.is_finalized,
header: header,
header,
}
};
@@ -548,7 +556,7 @@ impl Importer {
}).collect();
let route = chain.insert_block(&mut batch, block_data, receipts.clone(), ExtrasInsert {
fork_choice: fork_choice,
fork_choice,
is_finalized,
});
@@ -2410,11 +2418,11 @@ impl ImportSealedBlock for Client {
let _import_lock = self.importer.import_lock.lock();
trace_time!("import_sealed_block");
let block_data = block.rlp_bytes();
let block_bytes = block.rlp_bytes();
let pending = self.importer.check_epoch_end_signal(
&header,
&block_data,
&block_bytes,
&block.receipts,
block.state.db(),
self
@@ -2422,7 +2430,7 @@ impl ImportSealedBlock for Client {
let route = self.importer.commit_block(
block,
&header,
encoded::Block::new(block_data),
encoded::Block::new(block_bytes),
pending,
self
);