Skip to content
Snippets Groups Projects
Unverified Commit bea8baed authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

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.
parent 9643a3ad
No related merge requests found
Pipeline #406122 passed with stages
in 1 hour, 22 minutes, and 22 seconds
......@@ -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
},
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment