Skip to content

Commit

Permalink
Merge #1691
Browse files Browse the repository at this point in the history
1691: consensus: handle EBBs in rewindHeaderState r=nfrisby a=nfrisby

Fixes #1690.

I believe this bug was masked by Issue #1489; I discovered it and confirmed that this patch fixes it on my related WIP branch. This PR does not include a repro for this bug, but that branch does, and PR #1506 will as soon as I'm able to update it with that WIP branch -- that's my current focus.

Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
  • Loading branch information
iohk-bors[bot] and nfrisby committed Feb 25, 2020
2 parents a80b0ab + e09503c commit 3d2f492
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -192,6 +192,11 @@ castHeaderState HeaderState{..} = HeaderState{
castSeq :: (a -> b) -> StrictSeq a -> StrictSeq b
castSeq f = Seq.fromList . map f . toList

-- | Rewind the header state
--
-- This involves 'rewindChainState', and so inherits its PRECONDITION that the
-- target point must have been previously applied.
--
rewindHeaderState :: forall blk.
( BlockSupportsProtocol blk
, Serialise (HeaderHash blk)
Expand All @@ -210,8 +215,10 @@ rewindHeaderState cfg p HeaderState{..} = do
, headerStateAnchor = headerStateAnchor
}
where
-- the precondition ensures that @p@ is either in the old 'headerStateTips'
-- or the new 'headerStateTips' should indeed be empty
rolledBack :: AnnTip blk -> Bool
rolledBack t = annTipPoint t > p
rolledBack t = annTipPoint t /= p

{-------------------------------------------------------------------------------
Validate header envelope
Expand Down

0 comments on commit 3d2f492

Please sign in to comment.