Better error for spurious cache misses. (#4669)

Happened on Kusama for some not yet known reason.
This commit is contained in:
Robert Klotzner
2022-01-07 11:23:20 +01:00
committed by GitHub
parent c805500dfb
commit 2f1643b430
2 changed files with 11 additions and 7 deletions
@@ -144,10 +144,13 @@ impl SessionCache {
/// We assume validators in a group are tried in reverse order, so the reported bad validators
/// will be put at the beginning of the group.
pub fn report_bad(&mut self, report: BadValidators) -> crate::Result<()> {
let session = self
.session_info_cache
.get_mut(&report.session_index)
.ok_or(NonFatal::NoSuchCachedSession)?;
let available_sessions = self.session_info_cache.iter().map(|(k, _)| *k).collect();
let session = self.session_info_cache.get_mut(&report.session_index).ok_or(
NonFatal::NoSuchCachedSession {
available_sessions,
missing_session: report.session_index,
},
)?;
let group = session.validator_groups.get_mut(report.group_index.0 as usize).expect(
"A bad validator report must contain a valid group for the reported session. qed.",
);