From 72ff737d27be67d87308514b13e2574bc5f09fce Mon Sep 17 00:00:00 2001 From: thiolliere Date: Thu, 30 Jan 2020 11:19:18 +0100 Subject: [PATCH] safer end_era --- frame/staking/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index dfc116fbb8bc0..e3c6699400378 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -1542,7 +1542,14 @@ impl Module { } fn end_session(session_index: SessionIndex) { - if ErasStartSessionIndex::get(Self::active_era() + 1) == session_index + 1 { + let next_era_start = ErasStartSessionIndex::get(Self::active_era() + 1); + + if next_era_start < session_index + 1 { + frame_support::print("Error: some era ending has been missed"); + } + + // This should be a strict equality but better be safe in case ending has been missed. + if next_era_start <= session_index + 1 { Self::end_era(session_index); } }