Skip to content

Commit

Permalink
resource-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Jun 21, 2024
1 parent bee8628 commit 4f8aebf
Show file tree
Hide file tree
Showing 94 changed files with 990 additions and 414 deletions.
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ index-state:

packages:
nf-vars
resource-registry
ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-protocol
Expand Down
22 changes: 11 additions & 11 deletions nf-vars/src/Control/Concurrent/Class/MonadSTM/NormalForm.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module Control.Concurrent.Class.MonadSTM.NormalForm (
module Control.Concurrent.Class.MonadSTM.NormalForm.SVar
, module Control.Concurrent.Class.MonadSTM.NormalForm.TVar
, module Control.Concurrent.Class.MonadSTM.Strict.TBQueue
, module Control.Concurrent.Class.MonadSTM.Strict.TQueue
, module Control.Concurrent.Class.MonadSTM.Strict.TMVar
) where
module Control.Concurrent.Class.MonadSTM.NormalForm.SVar
, module Control.Concurrent.Class.MonadSTM.NormalForm.TVar
, module Control.Concurrent.Class.MonadSTM.Strict.TBQueue
, module Control.Concurrent.Class.MonadSTM.Strict.TMVar
, module Control.Concurrent.Class.MonadSTM.Strict.TQueue
) where

import Control.Concurrent.Class.MonadSTM.NormalForm.SVar
import Control.Concurrent.Class.MonadSTM.NormalForm.TVar
import Control.Concurrent.Class.MonadSTM.Strict.TBQueue
import Control.Concurrent.Class.MonadSTM.Strict.TQueue
import Control.Concurrent.Class.MonadSTM.Strict.TMVar
import Control.Concurrent.Class.MonadSTM.NormalForm.SVar
import Control.Concurrent.Class.MonadSTM.NormalForm.TVar
import Control.Concurrent.Class.MonadSTM.Strict.TBQueue
import Control.Concurrent.Class.MonadSTM.Strict.TMVar
import Control.Concurrent.Class.MonadSTM.Strict.TQueue
6 changes: 3 additions & 3 deletions nf-vars/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

module Main (main) where

import Control.Concurrent.Class.MonadSTM (MonadSTM)
import Control.Concurrent.Class.MonadSTM.NormalForm (newSVar,
updateSVar)
import Control.Monad.IOSim
import GHC.Generics
import NoThunks.Class
import Control.Concurrent.Class.MonadSTM.NormalForm (
newSVar, updateSVar)
import Control.Concurrent.Class.MonadSTM (MonadSTM)
import Test.Tasty
import Test.Tasty.QuickCheck

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ library unstable-cardano-tools
ouroboros-network-api,
ouroboros-network-framework ^>=0.13.2,
ouroboros-network-protocols,
resource-registry ^>=0.1,
serialise ^>=0.2,
singletons,
sop-core,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}

module Ouroboros.Consensus.Cardano.Block (
-- * Eras
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import qualified Cardano.Tools.DBAnalyser.HasAnalysis as HasAnalysis
import Codec.CBOR.Encoding (Encoding)
import Control.Monad (unless, void, when)
import Control.Monad.Except (runExcept)
import Control.ResourceRegistry
import Control.Tracer (Tracer (..), nullTracer, traceWith)
import Data.Int (Int64)
import Data.List (intercalate)
Expand Down Expand Up @@ -73,7 +74,6 @@ import Ouroboros.Consensus.Storage.LedgerDB (DiskSnapshot (..),
import Ouroboros.Consensus.Storage.Serialisation (SizeInBytes,
encodeDisk)
import qualified Ouroboros.Consensus.Util.IOLike as IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import System.FS.API (SomeHasFS (..))
import qualified System.IO as IO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Cardano.Tools.DBAnalyser.HasAnalysis
import Cardano.Tools.DBAnalyser.Types
import Codec.Serialise (Serialise (decode))
import Control.Monad.Except (runExceptT)
import Control.ResourceRegistry
import Control.Tracer (Tracer (..), nullTracer)
import Data.Singletons (Sing, SingI (..))
import qualified Debug.Trace as Debug
Expand All @@ -32,7 +33,6 @@ import Ouroboros.Consensus.Storage.LedgerDB (DiskSnapshot (..),
readSnapshot)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import System.IO


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Cardano.Tools.DBImmutaliser.Run (

import qualified Cardano.Tools.DBAnalyser.Block.Cardano as Cardano
import Cardano.Tools.DBAnalyser.HasAnalysis (mkProtocolInfo)
import Control.ResourceRegistry
import Control.Tracer (Tracer, stdoutTracer, traceWith)
import Data.Foldable (for_)
import Data.Functor.Contravariant ((>$<))
Expand All @@ -44,7 +45,6 @@ import qualified Ouroboros.Consensus.Storage.VolatileDB.API as VolatileDB
import qualified Ouroboros.Consensus.Storage.VolatileDB.Impl as VolatileDB
import Ouroboros.Consensus.Util.Args
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block (MaxSlotNo)
import System.FS.API (SomeHasFS (..))
import System.FS.API.Types (MountPoint (..))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Cardano.Tools.DBSynthesizer.Types
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Except.Extra (firstExceptT,
handleIOExceptT, hoistEither, runExceptT)
import Control.ResourceRegistry
import Control.Tracer (nullTracer)
import Data.Aeson as Aeson (FromJSON, Result (..), Value,
eitherDecodeFileStrict', eitherDecodeStrict', fromJSON)
Expand All @@ -34,7 +35,6 @@ import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB (getTipPoint)
import qualified Ouroboros.Consensus.Storage.ChainDB.Impl as ChainDB (withDB)
import qualified Ouroboros.Consensus.Storage.ChainDB.Impl.Args as ChainDB
import Ouroboros.Consensus.Util.IOLike (atomically)
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block
import Ouroboros.Network.Point (WithOrigin (..))
import System.Directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Cardano.Slotting.Slot (WithOrigin (..))
import Cardano.Tools.DBAnalyser.HasAnalysis
import Cardano.Tools.DBTruncater.Types
import Control.Monad
import Control.ResourceRegistry (runWithTempRegistry, withRegistry)
import Control.Tracer
import Data.Functor.Identity
import Data.Traversable (for)
Expand All @@ -24,8 +25,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB (ImmutableDB, Iterator,
import qualified Ouroboros.Consensus.Storage.ImmutableDB as ImmutableDB
import Ouroboros.Consensus.Storage.ImmutableDB.Impl
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry (runWithTempRegistry,
withRegistry)
import Prelude hiding (truncate)
import System.IO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
module Cardano.Tools.ImmDBServer.Diffusion (run) where

import Cardano.Tools.ImmDBServer.MiniProtocols (immDBServer)
import Control.ResourceRegistry
import Control.Tracer
import qualified Data.ByteString.Lazy as BL
import Data.Functor.Contravariant ((>$<))
Expand All @@ -22,7 +23,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB (ImmutableDbArgs (..))
import qualified Ouroboros.Consensus.Storage.ImmutableDB as ImmutableDB
import Ouroboros.Consensus.Util
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.ErrorPolicy (nullErrorPolicies)
import Ouroboros.Network.IOManager (withIOManager)
import Ouroboros.Network.Mux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Cardano.Tools.ImmDBServer.MiniProtocols (immDBServer) where
import qualified Codec.CBOR.Decoding as CBOR
import qualified Codec.CBOR.Encoding as CBOR
import Control.Monad (forever)
import Control.ResourceRegistry
import Control.Tracer
import Data.Bifunctor (bimap)
import qualified Data.ByteString.Lazy as BL
Expand All @@ -40,7 +41,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB.API (ImmutableDB)
import qualified Ouroboros.Consensus.Storage.ImmutableDB.API as ImmutableDB
import Ouroboros.Consensus.Util
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block (ChainUpdate (..), Tip (..))
import Ouroboros.Network.Driver (runPeer)
import Ouroboros.Network.KeepAlive (keepAliveServer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ library
filepath,
fs-api ^>=0.2.0.1,
hashable,
nf-vars,
io-classes ^>=1.5,
mtl,
nf-vars ^>=0.1,
ouroboros-consensus ^>=0.19,
ouroboros-network ^>=0.16,
ouroboros-network-api ^>=0.7.3,
ouroboros-network-framework ^>=0.13.2,
ouroboros-network-protocols ^>=0.9,
random,
resource-registry ^>=0.1,
safe-wild-cards ^>=1.0,
serialise ^>=0.2,
si-timers ^>=1.5,
Expand Down Expand Up @@ -148,6 +149,7 @@ library unstable-diffusion-testlib
ouroboros-network-protocols,
quiet ^>=0.2,
random,
resource-registry,
si-timers,
sop-core ^>=0.5,
sop-extras ^>=0.2,
Expand Down Expand Up @@ -297,6 +299,7 @@ test-suite consensus-test
quickcheck-state-machine:no-vendored-treediff,
quiet,
random,
resource-registry,
serialise,
si-timers,
sop-extras,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Codec.CBOR.Decoding (Decoder)
import Codec.CBOR.Encoding (Encoding)
import Codec.CBOR.Read (DeserialiseFailure)
import Codec.Serialise (Serialise)
import Control.ResourceRegistry
import Control.Tracer
import Data.ByteString.Lazy (ByteString)
import Data.Void (Void)
Expand All @@ -52,7 +53,6 @@ import qualified Ouroboros.Consensus.Storage.ChainDB.API as ChainDB
import Ouroboros.Consensus.Util (ShowProxy)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import qualified Ouroboros.Network.AnchoredFragment as AF
import Ouroboros.Network.Block (Serialised, decodePoint, decodeTip,
encodePoint, encodeTip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import Codec.CBOR.Read (DeserialiseFailure)
import Control.Concurrent.Class.MonadSTM.Strict.TVar as TVar.Unchecked
import Control.Monad.Class.MonadTime.SI (MonadTime)
import Control.Monad.Class.MonadTimer.SI (MonadTimer)
import Control.ResourceRegistry
import Control.Tracer
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as BSL
Expand Down Expand Up @@ -71,7 +72,6 @@ import Ouroboros.Consensus.Storage.Serialisation (SerialisedHeader)
import Ouroboros.Consensus.Util (ShowProxy)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block (Serialised (..), decodePoint,
decodeTip, encodePoint, encodeTip)
import Ouroboros.Network.BlockFetch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import Control.DeepSeq (NFData)
import Control.Monad (when)
import Control.Monad.Class.MonadTime.SI (MonadTime)
import Control.Monad.Class.MonadTimer.SI (MonadTimer)
import Control.ResourceRegistry
import Control.Tracer (Tracer, contramap, traceWith)
import Data.ByteString.Lazy (ByteString)
import Data.Functor.Contravariant (Predicate (..))
Expand Down Expand Up @@ -107,7 +108,6 @@ import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy
import Ouroboros.Consensus.Util.Args
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Consensus.Util.Time (secondsToNominalDiffTime)
import Ouroboros.Network.BlockFetch (BlockFetchConfiguration (..))
import qualified Ouroboros.Network.Diffusion as Diffusion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Ouroboros.Consensus.Node.ErrorPolicy (consensusErrorPolicy) where

import Control.Monad.Class.MonadAsync (ExceptionInLinkedThread (..))
import Control.ResourceRegistry (RegistryClosedException,
ResourceRegistryThreadException, TempRegistryException)
import Data.Proxy (Proxy)
import Data.Time.Clock (DiffTime)
import Data.Typeable (Typeable)
Expand All @@ -20,9 +22,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB.API (ImmutableDBError)
import qualified Ouroboros.Consensus.Storage.ImmutableDB.API as ImmutableDB
import Ouroboros.Consensus.Storage.VolatileDB.API (VolatileDBError)
import qualified Ouroboros.Consensus.Storage.VolatileDB.API as VolatileDB
import Ouroboros.Consensus.Util.ResourceRegistry
(RegistryClosedException, ResourceRegistryThreadException,
TempRegistryException)
import Ouroboros.Network.ErrorPolicy
import System.FS.API.Types (FsError)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module Ouroboros.Consensus.Node.GSM (
) where

import qualified Cardano.Slotting.Slot as Slot
import Control.Concurrent.Class.MonadSTM.NormalForm (StrictTVar)
import qualified Control.Concurrent.Class.MonadSTM.NormalForm as StrictSTM
import qualified Control.Concurrent.Class.MonadSTM.TVar as LazySTM
import Control.Monad (forever, join, unless)
import Control.Monad.Class.MonadSTM (MonadSTM, STM, atomically, check,
Expand All @@ -44,8 +46,6 @@ import qualified Ouroboros.Consensus.HardFork.History as HardFork
import qualified Ouroboros.Consensus.HardFork.History.Qry as Qry
import qualified Ouroboros.Consensus.Ledger.Basics as L
import Ouroboros.Consensus.Storage.ChainDB.API (ChainDB)
import Control.Concurrent.Class.MonadSTM.NormalForm (StrictTVar)
import qualified Control.Concurrent.Class.MonadSTM.NormalForm as StrictSTM
import Ouroboros.Network.PeerSelection.LedgerPeers.Type
(LedgerStateJudgement (..))
import System.FS.API (HasFS, createDirectoryIfMissing, doesFileExist,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Ouroboros.Consensus.Node.RethrowPolicy (consensusRethrowPolicy) where

import Control.Monad.Class.MonadAsync (ExceptionInLinkedThread (..))
import Control.ResourceRegistry (RegistryClosedException,
ResourceRegistryThreadException, TempRegistryException)
import Data.Proxy (Proxy)
import Data.Typeable (Typeable)
import Ouroboros.Consensus.Block (StandardHash)
Expand All @@ -19,9 +21,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB.API (ImmutableDBError)
import qualified Ouroboros.Consensus.Storage.ImmutableDB.API as ImmutableDB
import Ouroboros.Consensus.Storage.VolatileDB.API (VolatileDBError)
import qualified Ouroboros.Consensus.Storage.VolatileDB.API as VolatileDB
import Ouroboros.Consensus.Util.ResourceRegistry
(RegistryClosedException, ResourceRegistryThreadException,
TempRegistryException)
import Ouroboros.Network.RethrowPolicy
import System.FS.API.Types (FsError)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Control.DeepSeq (force)
import Control.Monad
import qualified Control.Monad.Class.MonadTimer.SI as SI
import Control.Monad.Except
import Control.ResourceRegistry
import Control.Tracer
import Data.Bifunctor (second)
import Data.Data (Typeable)
Expand Down Expand Up @@ -81,7 +82,6 @@ import Ouroboros.Consensus.Util.AnchoredFragment
import Ouroboros.Consensus.Util.EarlyExit
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Consensus.Util.STM
import Ouroboros.Network.AnchoredFragment (AnchoredFragment,
AnchoredSeq (..))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import Control.Monad
import Control.Monad.Class.MonadTime.SI (MonadTime)
import Control.Monad.Class.MonadTimer.SI (MonadTimer)
import qualified Control.Monad.Except as Exc
import Control.ResourceRegistry
import Control.Tracer
import qualified Data.ByteString.Lazy as Lazy
import Data.Either (isRight)
Expand Down Expand Up @@ -96,7 +97,6 @@ import Ouroboros.Consensus.Util.Enclose (pattern FallingEdge)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.RedundantConstraints
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Consensus.Util.STM
import Ouroboros.Consensus.Util.Time
import qualified Ouroboros.Network.AnchoredFragment as AF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ import Ouroboros.Network.Protocol.ChainSync.Codec
(ChainSyncTimeout (..))
import Ouroboros.Network.Protocol.Limits (shortWait)
import qualified Test.Consensus.BlockTree as BT
import Test.Consensus.PointSchedule
import qualified Test.Consensus.ChainGenerator.Adversarial as A
import Test.Consensus.ChainGenerator.Adversarial
(genPrefixBlockCount)
import Test.Consensus.ChainGenerator.Counting
(Count (Count), getVector)
import Test.Consensus.ChainGenerator.Adversarial (genPrefixBlockCount)
import Test.Consensus.ChainGenerator.Counting (Count (Count),
getVector)
import qualified Test.Consensus.ChainGenerator.Honest as H
import Test.Consensus.ChainGenerator.Honest
(ChainSchema (ChainSchema), HonestRecipe (..))
import Test.Consensus.ChainGenerator.Params
import qualified Test.Consensus.ChainGenerator.Slot as S
import Test.Consensus.ChainGenerator.Slot (S)
import Test.Consensus.PointSchedule
import qualified Test.QuickCheck as QC
import Test.QuickCheck.Extras (unsafeMapSuchThatJust)
import Test.QuickCheck.Random (QCGen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Ouroboros.Network.Protocol.ChainSync.Codec
(ChainSyncTimeout (..))
import Ouroboros.Network.Protocol.Limits (shortWait)
import Test.Consensus.BlockTree (BlockTree (..), btbSuffix)
import Test.Consensus.ChainGenerator.Params (Delta (Delta))
import Test.Consensus.Genesis.Setup
import Test.Consensus.Genesis.Setup.Classifiers
import Test.Consensus.PeerSimulator.ChainSync (chainSyncNoTimeouts)
Expand All @@ -46,7 +47,6 @@ import Test.Consensus.PointSchedule.Shrinking
(shrinkByRemovingAdversaries, shrinkPeerSchedules)
import Test.Consensus.PointSchedule.SinglePeer
(SchedulePoint (ScheduleBlockPoint, ScheduleTipPoint))
import Test.Consensus.ChainGenerator.Params (Delta (Delta))
import qualified Test.QuickCheck as QC
import Test.QuickCheck
import Test.Tasty
Expand Down
Loading

0 comments on commit 4f8aebf

Please sign in to comment.