Skip to content

Commit d72c567

Browse files
committed
fix several NoThunks issues:
- cdbLoE -> !cdbLoE - swap String for Text in Fuse - tblcForecastRange :: Maybe SlotNo -> tblcForecastRange :: !(StrictMaybe SlotNo) - tblcHardForkParams :: EraParams -> tblcHardForkParams :: !EraParams - use `newUncheckedTVarM` in Test.Consensus.BlockChainTime.Simple - LoEEnabled a -> LoEEnabled !a - newState -> !newState in LeakyBucket - add bangs to all fields of TestBlockWith - csLatestSlot :: Maybe (WithOrigin SlotNo) -> csLatestSlot :: !(StrictMaybe (WithOrigin SlotNo))
1 parent 0f4c374 commit d72c567

File tree

14 files changed

+38
-28
lines changed

14 files changed

+38
-28
lines changed

ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ test-suite consensus-test
275275
bytestring,
276276
cardano-crypto-class,
277277
cardano-slotting:{cardano-slotting, testlib},
278+
cardano-strict-containers,
278279
containers,
279280
contra-tracer,
280281
directory,

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/Genesis/Tests/DensityDisconnect.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Data.List.NonEmpty (nonEmpty)
1818
import Data.Map.Strict (Map)
1919
import qualified Data.Map.Strict as Map
2020
import Data.Maybe (fromMaybe)
21+
import Data.Maybe.Strict (StrictMaybe (..))
2122
import Data.Semigroup (Endo (..))
2223
import Data.Set (Set, (\\))
2324
import qualified Data.Set as Set
@@ -141,7 +142,7 @@ prop_densityDisconnectStatic =
141142
mkState frag =
142143
ChainSyncState {
143144
csCandidate = frag,
144-
csLatestSlot = Just (AF.headSlot frag),
145+
csLatestSlot = SJust (AF.headSlot frag),
145146
csIdling = False
146147
}
147148
gen = do
@@ -377,7 +378,7 @@ evolveBranches EvolvingPeers {k, sgen, peers = initialPeers, fullTree} =
377378
ChainSyncState {
378379
csCandidate,
379380
csIdling = False,
380-
csLatestSlot = Just (AF.headSlot csCandidate)
381+
csLatestSlot = SJust (AF.headSlot csCandidate)
381382
}
382383
-- Run GDD.
383384
(loeFrag, suffixes) = sharedCandidatePrefix curChain candidates

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/PeerSimulator/Config.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Test.Consensus.PeerSimulator.Config (defaultCfg) where
55
import Cardano.Crypto.DSIGN (SignKeyDSIGN (..), VerKeyDSIGN (..))
66
import Cardano.Slotting.Time (SlotLength, slotLengthFromSec)
77
import qualified Data.Map.Strict as Map
8+
import Data.Maybe.Strict (StrictMaybe (..))
89
import Ouroboros.Consensus.Config (SecurityParam, TopLevelConfig (..),
910
emptyCheckpointsMap)
1011
import Ouroboros.Consensus.HardFork.History
@@ -39,7 +40,7 @@ defaultCfg secParam (ForecastRange sfor) sgen = TopLevelConfig {
3940
, (CoreId (CoreNodeId 1), VerKeyMockDSIGN 1)
4041
]
4142
}
42-
, topLevelConfigLedger = TestBlockLedgerConfig eraParams (Just $ fromIntegral sfor)
43+
, topLevelConfigLedger = TestBlockLedgerConfig eraParams (SJust (fromIntegral sfor))
4344
, topLevelConfigBlock = TestBlockConfig numCoreNodes
4445
, topLevelConfigCodec = TestBlockCodecConfig
4546
, topLevelConfigStorage = TestBlockStorageConfig

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Genesis/Governor.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module Ouroboros.Consensus.Genesis.Governor (
3737
import Control.Monad (guard)
3838
import Control.Tracer (Tracer, traceWith)
3939
import Data.Containers.ListUtils (nubOrd)
40-
import Data.Foldable (for_)
40+
import Data.Foldable (for_, toList)
4141
import Data.Map.Strict (Map)
4242
import qualified Data.Map.Strict as Map
4343
import Data.Maybe (maybeToList)
@@ -212,7 +212,7 @@ densityDisconnect (GenesisWindow sgen) (SecurityParam k) states candidateSuffixe
212212
state <- maybeToList (states Map.!? peer)
213213
-- Skip peers that haven't sent any headers yet.
214214
-- They should be disconnected by timeouts instead.
215-
latestSlot <- maybeToList (csLatestSlot state)
215+
latestSlot <- toList (csLatestSlot state)
216216
let candidateSuffix = candidateSuffixes Map.! peer
217217

218218
idling = csIdling state

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ChainSync/Client.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import Data.Kind (Type)
8080
import Data.Map.Strict (Map)
8181
import qualified Data.Map.Strict as Map
8282
import Data.Maybe (fromMaybe)
83+
import Data.Maybe.Strict (StrictMaybe (..))
8384
import Data.Proxy
8485
import Data.Typeable
8586
import Data.Word (Word64)
@@ -349,7 +350,7 @@ bracketChainSyncClient
349350
csvSetCandidate =
350351
modifyTVar csHandleState . \ c s -> s {csCandidate = c}
351352
, csvSetLatestSlot =
352-
modifyTVar csHandleState . \ ls s -> s {csLatestSlot = Just $! ls}
353+
modifyTVar csHandleState . \ ls s -> s {csLatestSlot = SJust ls}
353354
, csvIdling = Idling {
354355
idlingStart = atomically $ modifyTVar csHandleState $ \ s -> s {csIdling = True}
355356
, idlingStop = atomically $ modifyTVar csHandleState $ \ s -> s {csIdling = False}
@@ -365,7 +366,7 @@ bracketChainSyncClient
365366
mkChainSyncClientHandleState =
366367
newTVarIO ChainSyncState {
367368
csCandidate = AF.Empty AF.AnchorGenesis
368-
, csLatestSlot = Nothing
369+
, csLatestSlot = SNothing
369370
, csIdling = False
370371
}
371372

@@ -1001,7 +1002,7 @@ findIntersectionTop cfgEnv dynEnv intEnv =
10011002
map castPoint
10021003
$ AF.selectPoints (map fromIntegral offsets) ourFrag
10031004

1004-
uis = UnknownIntersectionState {
1005+
!uis = UnknownIntersectionState {
10051006
ourFrag = ourFrag
10061007
, ourHeaderStateHistory = ourHeaderStateHistory
10071008
, uBestBlockNo

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ChainSync/Client/Jumping.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ import Data.List (sortOn)
167167
import Data.Map.Strict (Map)
168168
import qualified Data.Map.Strict as Map
169169
import Data.Maybe (catMaybes, fromMaybe)
170+
import Data.Maybe.Strict (StrictMaybe (..))
170171
import GHC.Generics (Generic)
171172
import Ouroboros.Consensus.Block (HasHeader (getHeaderFields), Header,
172173
Point (..), castPoint, pointSlot, succWithOrigin)
@@ -587,7 +588,7 @@ processJumpResult context jumpResult =
587588
updateChainSyncState handle jump = do
588589
let fragment = jTheirFragment jump
589590
modifyTVar (cschState handle) $ \csState ->
590-
csState {csCandidate = fragment, csLatestSlot = Just (AF.headSlot fragment) }
591+
csState {csCandidate = fragment, csLatestSlot = SJust (AF.headSlot fragment) }
591592
writeTVar (cschJumpInfo handle) $ Just jump
592593

593594
mkGoodJumpInfo :: Maybe (JumpInfo blk) -> JumpInfo blk -> JumpInfo blk

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ChainSync/Client/State.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Ouroboros.Consensus.MiniProtocol.ChainSync.Client.State (
2121

2222
import Cardano.Slotting.Slot (SlotNo, WithOrigin)
2323
import Data.Function (on)
24+
import Data.Maybe.Strict (StrictMaybe (..))
2425
import Data.Typeable (Proxy (..), typeRep)
2526
import GHC.Generics (Generic)
2627
import Ouroboros.Consensus.Block (HasHeader, Header, Point)
@@ -56,7 +57,7 @@ data ChainSyncState blk = ChainSyncState {
5657
-- processing it further, and the latest slot may refer to a header beyond
5758
-- the forecast horizon while the candidate fragment isn't extended yet, to
5859
-- signal to GDD that the density is known up to this slot.
59-
, csLatestSlot :: !(Maybe (WithOrigin SlotNo))
60+
, csLatestSlot :: !(StrictMaybe (WithOrigin SlotNo))
6061
}
6162
deriving stock (Generic)
6263

@@ -131,15 +132,15 @@ data ChainSyncJumpingState m blk
131132
-- honest, but the goal of the algorithm is to eventually have an honest,
132133
-- alert peer as dynamo.
133134
Dynamo
134-
(DynamoInitState blk)
135+
!(DynamoInitState blk)
135136
-- | The last slot at which we triggered jumps for the jumpers.
136137
!(WithOrigin SlotNo)
137138
| -- | The objector, of which there is at most one, also runs normal
138139
-- ChainSync. It is a former jumper that disagreed with the dynamo. When
139140
-- that happened, we spun it up to let normal ChainSync and Genesis decide
140141
-- which one to disconnect from.
141142
Objector
142-
ObjectorInitState
143+
!ObjectorInitState
143144
-- | The youngest point where the objector agrees with the dynamo.
144145
!(JumpInfo blk)
145146
-- | The point where the objector dissented with the dynamo when it was a

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/ChainDB/API.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ data LoE a =
887887
-- When the selection's tip is @k@ blocks after the earliest intersection of
888888
-- of all candidate fragments, ChainSel will not add new blocks to the
889889
-- selection.
890-
LoEEnabled a
890+
LoEEnabled !a
891891
deriving (Eq, Show, Generic, NoThunks, Functor, Foldable, Traversable)
892892

893893
type GetLoEFragment m blk = LoE (m (AnchoredFragment (Header blk)))

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE FlexibleContexts #-}
22
{-# LANGUAGE LambdaCase #-}
3+
{-# LANGUAGE OverloadedStrings #-}
34
{-# LANGUAGE RecordWildCards #-}
45
{-# LANGUAGE ScopedTypeVariables #-}
56
{-# LANGUAGE TypeApplications #-}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ data ChainDbEnv m blk = CDB
268268
-- The number of blocks from the future is bounded by the number of
269269
-- upstream peers multiplied by the max clock skew divided by the slot
270270
-- length.
271-
, cdbLoE :: LoE (m (AnchoredFragment (Header blk)))
271+
, cdbLoE :: !(LoE (m (AnchoredFragment (Header blk))))
272272
-- ^ Configure the Limit on Eagerness. If this is 'LoEEnabled', it contains
273273
-- an action that returns the LoE fragment, which indicates the latest rollback
274274
-- point, i.e. we are not allowed to select a chain from which we could not

0 commit comments

Comments
 (0)