@@ -181,8 +181,9 @@ loadSkovData ::
181
181
RuntimeParameters ->
182
182
-- | Set to 'True' if a rollback occurred before loading the skov
183
183
Bool ->
184
- -- | The 'SkovData' and, if the consensus is shutdown, the effective protocol update.
185
- m (SkovData pv , Maybe ProtocolUpdate )
184
+ -- | The 'SkovData' and, if the consensus is shutdown, the effective protocol update and
185
+ -- relative block height of the terminal block.
186
+ m (SkovData pv , Maybe (ProtocolUpdate , BlockHeight ))
186
187
loadSkovData _genesisBlockHeight _runtimeParameters didRollback = do
187
188
_persistentRoundStatus <- LowLevel. lookupCurrentRoundStatus
188
189
mLatestFinEntry <- LowLevel. lookupLatestFinalizationEntry
@@ -238,10 +239,6 @@ loadSkovData _genesisBlockHeight _runtimeParameters didRollback = do
238
239
-- seedstate, the consensus is shutdown, so we determine the shutdown trigger block, which
239
240
-- will be the terminal block. The terminal block may differ from the last finalized block.
240
241
let consensusIsShutdown = lastFinSeedState ^. shutdownTriggered
241
- _terminalBlock <-
242
- if consensusIsShutdown
243
- then Present <$> findShutdownTriggerBlock lastFinBlock
244
- else return Absent
245
242
(currentEpoch, lastEpochFinEntry) <-
246
243
if lastFinSeedState ^. epochTransitionTriggered
247
244
&& not consensusIsShutdown
@@ -288,16 +285,18 @@ loadSkovData _genesisBlockHeight _runtimeParameters didRollback = do
288
285
_focusBlock = lastFinBlock
289
286
}
290
287
let _statistics = Stats. initialConsensusStatistics
291
- protocolUpdate <-
288
+ (_terminalBlock, protocolUpdate) <-
292
289
if consensusIsShutdown
293
290
then do
294
291
getProtocolUpdateStatus (bpState lastFinBlock) >>= \ case
295
- ProtocolUpdated pu -> return $ Just pu
292
+ ProtocolUpdated pu -> do
293
+ termBlock <- findShutdownTriggerBlock lastFinBlock
294
+ return (Present termBlock, Just (pu, blockHeight termBlock))
296
295
PendingProtocolUpdates {} ->
297
296
throwM . TreeStateInvariantViolation $
298
297
" Consensus is shut down, but no effective protocol update was present \
299
298
\in the last finalized block."
300
- else return Nothing
299
+ else return ( Absent , Nothing )
301
300
return (SkovData {.. }, protocolUpdate)
302
301
303
302
-- | Load the certified blocks from the low-level database into the tree state.
@@ -454,7 +453,7 @@ loadCertifiedBlocks = do
454
453
Nothing -> liftIO DiffMap. newEmptyReference
455
454
Just diffMapReference -> return diffMapReference
456
455
newDifferenceMap <- reconstructAccountDifferenceMap (bpState blockPointer) parentDiffMapReference accountsToInsert
457
- -- append to the accummulator with this new difference map reference
456
+ -- append to the accumulator with this new difference map reference
458
457
let loadedBlocks' = HM. insert (getHash storedBlock) newDifferenceMap loadedBlocks
459
458
460
459
cacheBlockState (bpState blockPointer)
0 commit comments