mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
level-monitor: Fix issue with warp syncing (#2053)
When warp syncing a node we import a header of the parachain around the tip of the chain. This header is currently not imported as finalized block (should be fixed at some point as well), the parent headers are not yet present (still being synced) and thus, we run into a panic. Even if there is a case where a leaf could not be found in the database, this probably means that the db is broken and it will fail somewhere elese.
This commit is contained in:
@@ -98,7 +98,6 @@ where
|
||||
///
|
||||
/// Level limits are not enforced during this phase.
|
||||
fn restore(&mut self) {
|
||||
const ERR_MSG: &str = "route from finalized to leaf should be available; qed";
|
||||
let info = self.backend.blockchain().info();
|
||||
|
||||
log::debug!(
|
||||
@@ -112,7 +111,14 @@ where
|
||||
self.import_counter = info.finalized_number;
|
||||
|
||||
for leaf in self.backend.blockchain().leaves().unwrap_or_default() {
|
||||
let mut meta = self.backend.blockchain().header_metadata(leaf).expect(ERR_MSG);
|
||||
let Ok(mut meta) = self.backend.blockchain().header_metadata(leaf) else {
|
||||
log::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Could not fetch header metadata for leaf: {leaf:?}",
|
||||
);
|
||||
|
||||
continue
|
||||
};
|
||||
|
||||
self.import_counter = self.import_counter.max(meta.number);
|
||||
|
||||
@@ -123,7 +129,19 @@ where
|
||||
if meta.number <= self.lowest_level {
|
||||
break
|
||||
}
|
||||
meta = self.backend.blockchain().header_metadata(meta.parent).expect(ERR_MSG);
|
||||
|
||||
meta = match self.backend.blockchain().header_metadata(meta.parent) {
|
||||
Ok(m) => m,
|
||||
Err(_) => {
|
||||
// This can happen after we have warp synced a node.
|
||||
log::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Could not fetch header metadata for parent: {:?}",
|
||||
meta.parent,
|
||||
);
|
||||
break
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user