Skip to content

Commit

Permalink
Work around a strange space leak in PBFT.ChainState
Browse files Browse the repository at this point in the history
Stop-gap solution for #1356.
  • Loading branch information
mrBliss committed Dec 16, 2019
1 parent b0eb2fd commit 56f0cc4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,15 @@ append :: forall c. PBftCrypto c
-> PBftChainState c -> PBftChainState c
append k n signer@(PBftSigner _ gk) PBftChainState{..} =
assertInvariant k n $
pruneEBBsLT $
PBftChainState {
preAnchor = preAnchor'
, postAnchor = postAnchor'
, preWindow = preWindow'
, inWindow = inWindow'
, counts = updateCounts counts
, ebbs = ebbs -- NB this needs to be pruned
-- NOTE: 'pruneEBBsLT' is inlined here to avoid a strange space leak
-- that also goes away with @-O0@, see #1356.
, ebbs = EbbMap $ Map.filter (>= anchorSlot') (unEbbMap ebbs)
}
where
(preAnchor', postAnchor') =
Expand All @@ -381,6 +382,10 @@ append k n signer@(PBftSigner _ gk) PBftChainState{..} =
, incrementKey gk
)

anchorSlot' = case preAnchor' of
_ :|> anchorSigner -> At (pbftSignerSlotNo anchorSigner)
_otherwise -> Origin

-- | Rewind the state to the specified slot
--
-- This matches the semantics of 'rewindChainState' in 'OuroborosTag', in that
Expand Down

0 comments on commit 56f0cc4

Please sign in to comment.