Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

level-monitor: Fix issue with warp syncing #2053

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions cumulus/client/consensus/common/src/level_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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);

Expand All @@ -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
},
}
}
}

Expand Down