Initial sync block stuck. Block import logs (#318)
Co-authored-by: Karim Agha <karim.dev@gmail.com>
This commit is contained in:
parent
b6b5129058
commit
33a3a9deec
@ -284,7 +284,9 @@ impl Importer {
|
|||||||
// t_nb 6.0 This is triggered by a message coming from a block queue when the block is ready for insertion
|
// t_nb 6.0 This is triggered by a message coming from a block queue when the block is ready for insertion
|
||||||
pub fn import_verified_blocks(&self, client: &Client) -> usize {
|
pub fn import_verified_blocks(&self, client: &Client) -> usize {
|
||||||
// Shortcut out if we know we're incapable of syncing the chain.
|
// Shortcut out if we know we're incapable of syncing the chain.
|
||||||
|
trace!(target: "block_import", "fn import_verified_blocks");
|
||||||
if !client.enabled.load(AtomicOrdering::SeqCst) {
|
if !client.enabled.load(AtomicOrdering::SeqCst) {
|
||||||
|
self.block_queue.reset_verification_ready_signal();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +308,8 @@ impl Importer {
|
|||||||
let _import_lock = self.import_lock.lock();
|
let _import_lock = self.import_lock.lock();
|
||||||
let blocks = self.block_queue.drain(max_blocks_to_import);
|
let blocks = self.block_queue.drain(max_blocks_to_import);
|
||||||
if blocks.is_empty() {
|
if blocks.is_empty() {
|
||||||
|
debug!(target: "block_import", "block_queue is empty");
|
||||||
|
self.block_queue.resignal_verification();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
trace_time!("import_verified_blocks");
|
trace_time!("import_verified_blocks");
|
||||||
@ -318,6 +322,13 @@ impl Importer {
|
|||||||
|
|
||||||
let is_invalid = invalid_blocks.contains(header.parent_hash());
|
let is_invalid = invalid_blocks.contains(header.parent_hash());
|
||||||
if is_invalid {
|
if is_invalid {
|
||||||
|
debug!(
|
||||||
|
target: "block_import",
|
||||||
|
"Refusing block #{}({}) with invalid parent {}",
|
||||||
|
header.number(),
|
||||||
|
header.hash(),
|
||||||
|
header.parent_hash()
|
||||||
|
);
|
||||||
invalid_blocks.insert(hash);
|
invalid_blocks.insert(hash);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -326,7 +337,7 @@ impl Importer {
|
|||||||
Ok((closed_block, pending)) => {
|
Ok((closed_block, pending)) => {
|
||||||
imported_blocks.push(hash);
|
imported_blocks.push(hash);
|
||||||
let transactions_len = closed_block.transactions.len();
|
let transactions_len = closed_block.transactions.len();
|
||||||
|
trace!(target:"block_import","Block #{}({}) check pass",header.number(),header.hash());
|
||||||
// t_nb 8.0 commit block to db
|
// t_nb 8.0 commit block to db
|
||||||
let route = self.commit_block(
|
let route = self.commit_block(
|
||||||
closed_block,
|
closed_block,
|
||||||
@ -335,6 +346,7 @@ impl Importer {
|
|||||||
pending,
|
pending,
|
||||||
client,
|
client,
|
||||||
);
|
);
|
||||||
|
trace!(target:"block_import","Block #{}({}) commited",header.number(),header.hash());
|
||||||
import_results.push(route);
|
import_results.push(route);
|
||||||
client
|
client
|
||||||
.report
|
.report
|
||||||
@ -368,6 +380,7 @@ impl Importer {
|
|||||||
|
|
||||||
{
|
{
|
||||||
if !imported_blocks.is_empty() {
|
if !imported_blocks.is_empty() {
|
||||||
|
trace!(target:"block_import","Imported block, notify rest of system");
|
||||||
let route = ChainRoute::from(import_results.as_ref());
|
let route = ChainRoute::from(import_results.as_ref());
|
||||||
|
|
||||||
// t_nb 10 Notify miner about new included block.
|
// t_nb 10 Notify miner about new included block.
|
||||||
@ -396,11 +409,12 @@ impl Importer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
trace!(target:"block_import","Flush block to db");
|
||||||
let db = client.db.read();
|
let db = client.db.read();
|
||||||
db.key_value().flush().expect("DB flush failed.");
|
db.key_value().flush().expect("DB flush failed.");
|
||||||
|
|
||||||
self.block_queue.resignal_verification();
|
self.block_queue.resignal_verification();
|
||||||
|
trace!(target:"block_import","Resignal verifier");
|
||||||
imported
|
imported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,6 +678,11 @@ impl<K: Kind> VerificationQueue<K> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reset verification ready signal so that it allows other threads to send IoMessage to Client
|
||||||
|
pub fn reset_verification_ready_signal(&self) {
|
||||||
|
self.ready_signal.reset();
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if there is nothing currently in the queue.
|
/// Returns true if there is nothing currently in the queue.
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
let v = &self.verification;
|
let v = &self.verification;
|
||||||
|
Loading…
Reference in New Issue
Block a user