Skip to content

Commit 5c2bd47

Browse files
committed
ChainSel: reprocess LoE-delayed blocks even when LoE is disabled
When Genesis is disable statically, we never even schedule any LoE reprocessing, so this doesn't change anything in this situation. When Genesis is disabled and we are caught-up, then there are concrete scenarios where we want to reprocess LoE blocks, see the preceding two commits.
1 parent b4e886f commit 5c2bd47

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Patch
2+
3+
- Changed ChainSel to reprocess LoE-delayed blocks even when LoE is disabled.

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/ChainDB/Impl/ChainSel.hs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -332,29 +332,29 @@ chainSelSync ::
332332
-- We run a background thread that polls the candidate fragments and sends
333333
-- 'ChainSelReprocessLoEBlocks' whenever we receive a new header or lose a
334334
-- peer.
335-
-- If 'cdbLoE' is 'LoEDisabled', this task is skipped.
335+
--
336+
-- Note that we do this even when we are caught-up, as we might want to select
337+
-- blocks that were originally postponed by the LoE, but can be adopted once we
338+
-- conclude that we are caught-up (and hence are longer bound by the LoE).
336339
chainSelSync cdb@CDB{..} (ChainSelReprocessLoEBlocks varProcessed) = do
337-
lift cdbLoE >>= \case
338-
LoEDisabled -> pure ()
339-
LoEEnabled _ -> do
340-
(succsOf, chain) <- lift $ atomically $ do
341-
invalid <- forgetFingerprint <$> readTVar cdbInvalid
342-
(,)
343-
<$> (ignoreInvalidSuc cdbVolatileDB invalid <$>
344-
VolatileDB.filterByPredecessor cdbVolatileDB)
345-
<*> Query.getCurrentChain cdb
346-
let
347-
succsOf' = Set.toList . succsOf . pointHash . castPoint
348-
loeHashes = succsOf' (AF.anchorPoint chain)
349-
firstHeader = either (const Nothing) Just $ AF.last chain
350-
-- We avoid the VolatileDB for the headers we already have in the chain
351-
getHeaderFromHash hash =
352-
case firstHeader of
353-
Just header | headerHash header == hash -> pure header
354-
_ -> VolatileDB.getKnownBlockComponent cdbVolatileDB GetHeader hash
355-
loeHeaders <- lift (mapM getHeaderFromHash loeHashes)
356-
for_ loeHeaders $ \hdr ->
357-
chainSelectionForBlock cdb BlockCache.empty hdr noPunishment
340+
(succsOf, chain) <- lift $ atomically $ do
341+
invalid <- forgetFingerprint <$> readTVar cdbInvalid
342+
(,)
343+
<$> (ignoreInvalidSuc cdbVolatileDB invalid <$>
344+
VolatileDB.filterByPredecessor cdbVolatileDB)
345+
<*> Query.getCurrentChain cdb
346+
let
347+
succsOf' = Set.toList . succsOf . pointHash . castPoint
348+
loeHashes = succsOf' (AF.anchorPoint chain)
349+
firstHeader = either (const Nothing) Just $ AF.last chain
350+
-- We avoid the VolatileDB for the headers we already have in the chain
351+
getHeaderFromHash hash =
352+
case firstHeader of
353+
Just header | headerHash header == hash -> pure header
354+
_ -> VolatileDB.getKnownBlockComponent cdbVolatileDB GetHeader hash
355+
loeHeaders <- lift (mapM getHeaderFromHash loeHashes)
356+
for_ loeHeaders $ \hdr ->
357+
chainSelectionForBlock cdb BlockCache.empty hdr noPunishment
358358
lift $ atomically $ putTMVar varProcessed ()
359359

360360
chainSelSync cdb@CDB {..} (ChainSelAddBlock BlockToAdd { blockToAdd = b, .. }) = do

0 commit comments

Comments
 (0)