Skip to content
Permalink
Browse files

Fix infinite loop in chain selection

When a candidate chain contains an invalid block, we take the valid prefix of
that candidate and continue chain selection using that candidate. In the
computation of that prefix, we were taking the prefix of the result of the
computation instead of the original candidate and boom, infinite loop...

We currently don't test with invalid blocks (on the list of TODOs!), so this
wasn't detected before. This infinite loop was discovered when running the
demo with `--real-pbft`, which can result in invalid blocks.
  • Loading branch information...
mrBliss committed Jul 12, 2019
1 parent 76bb5c1 commit 59bbb0824246392a675cf9b5fad5f78f1e7b45b2
Showing with 1 addition and 1 deletion.
  1. +1 −1 ouroboros-consensus/src/Ouroboros/Storage/ChainDB/Impl/ChainSel.hs
@@ -615,7 +615,7 @@ validateCandidate lgrDB tracer cfg invalidPoints
let lastValid = castPoint $ LgrDB.currentPoint ledger'
candidate' = fromMaybe
(error "cannot rollback to point on fragment") $
AF.rollback lastValid candidate'
AF.rollback lastValid candidate
let invalidPointsInCand = Set.fromList $ pointsStartingFrom pt
atomically $ modifyTVar' invalidPoints (Set.union invalidPointsInCand)
trace (InvalidBlock e pt)

0 comments on commit 59bbb08

Please sign in to comment.
You can’t perform that action at this time.