From a38988a266ee2e78cf3633551aeb466a47de71ec Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 1 Oct 2025 12:16:51 +0200 Subject: [PATCH 01/24] ouroboros-network: removed NodeTo{Node,Client} modules They were moved to `ouroboros-network:cardano-diffusion` in a previous PR. --- .../src/Ouroboros/Network/NodeToClient.hs | 327 ------------- .../src/Ouroboros/Network/NodeToNode.hs | 440 ------------------ 2 files changed, 767 deletions(-) delete mode 100644 ouroboros-network/src/Ouroboros/Network/NodeToClient.hs delete mode 100644 ouroboros-network/src/Ouroboros/Network/NodeToNode.hs diff --git a/ouroboros-network/src/Ouroboros/Network/NodeToClient.hs b/ouroboros-network/src/Ouroboros/Network/NodeToClient.hs deleted file mode 100644 index d6655827e4b..00000000000 --- a/ouroboros-network/src/Ouroboros/Network/NodeToClient.hs +++ /dev/null @@ -1,327 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE PolyKinds #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} - --- | This is the starting point for a module that will bring together the --- overall node to client protocol, as a collection of mini-protocols. --- -module Ouroboros.Network.NodeToClient - ( nodeToClientProtocols - , NodeToClientProtocols (..) - , NodeToClientVersion (..) - , NodeToClientVersionData (..) - , NetworkConnectTracers (..) - , nullNetworkConnectTracers - , connectTo - , connectToWithMux - -- * Null Protocol Peers - , chainSyncPeerNull - , localStateQueryPeerNull - , localTxSubmissionPeerNull - , localTxMonitorPeerNull - -- * Re-exported network interface - , IOManager (..) - , AssociateWithIOCP - , withIOManager - , LocalSnocket - , localSnocket - , LocalSocket (..) - , LocalAddress (..) - , LocalConnectionId - -- * Versions - , Versions (..) - , versionedNodeToClientProtocols - , simpleSingletonVersions - , foldMapVersions - , combineVersions - -- ** Codecs - , nodeToClientHandshakeCodec - , nodeToClientVersionCodec - , nodeToClientCodecCBORTerm - -- * Re-exports - , ConnectionId (..) - , MinimalInitiatorContext (..) - , ResponderContext (..) - , TraceSendRecv (..) - , ProtocolLimitFailure - , Handshake - , HandshakeTr - ) where - -import Control.Concurrent.Async qualified as Async -import Control.Exception (SomeException) -import Control.Monad (forever) -import Control.Monad.Class.MonadTimer.SI - -import Codec.CBOR.Term qualified as CBOR -import Data.ByteString.Lazy qualified as BL -import Data.Kind (Type) -import Data.Void (Void, absurd) - -import Network.Mux qualified as Mx -import Network.TypedProtocol.Peer.Client -import Network.TypedProtocol.Stateful.Peer.Client qualified as Stateful - -import Ouroboros.Network.Context -import Ouroboros.Network.Driver (TraceSendRecv (..)) -import Ouroboros.Network.Driver.Limits (ProtocolLimitFailure (..)) -import Ouroboros.Network.IOManager -import Ouroboros.Network.Mux -import Ouroboros.Network.NodeToClient.Version -import Ouroboros.Network.Protocol.ChainSync.Client as ChainSync -import Ouroboros.Network.Protocol.ChainSync.Type qualified as ChainSync -import Ouroboros.Network.Protocol.Handshake.Codec -import Ouroboros.Network.Protocol.Handshake.Type -import Ouroboros.Network.Protocol.Handshake.Version hiding (Accept) -import Ouroboros.Network.Protocol.LocalStateQuery.Client as LocalStateQuery -import Ouroboros.Network.Protocol.LocalStateQuery.Type qualified as LocalStateQuery -import Ouroboros.Network.Protocol.LocalTxMonitor.Client as LocalTxMonitor -import Ouroboros.Network.Protocol.LocalTxMonitor.Type qualified as LocalTxMonitor -import Ouroboros.Network.Protocol.LocalTxSubmission.Client as LocalTxSubmission -import Ouroboros.Network.Protocol.LocalTxSubmission.Type qualified as LocalTxSubmission -import Ouroboros.Network.Snocket -import Ouroboros.Network.Socket - --- The Handshake tracer types are simply terrible. -type HandshakeTr ntcAddr ntcVersion = - Mx.WithBearer (ConnectionId ntcAddr) - (TraceSendRecv (Handshake ntcVersion CBOR.Term)) - - --- | Record of node-to-client mini protocols. --- -data NodeToClientProtocols appType ntcAddr bytes m a b = NodeToClientProtocols { - -- | local chain-sync mini-protocol - -- - localChainSyncProtocol :: RunMiniProtocolWithMinimalCtx - appType ntcAddr bytes m a b, - - -- | local tx-submission mini-protocol - -- - localTxSubmissionProtocol :: RunMiniProtocolWithMinimalCtx - appType ntcAddr bytes m a b, - - -- | local state-query mini-protocol - -- - localStateQueryProtocol :: RunMiniProtocolWithMinimalCtx - appType ntcAddr bytes m a b, - - -- | local tx-monitor mini-protocol - -- - localTxMonitorProtocol :: RunMiniProtocolWithMinimalCtx - appType ntcAddr bytes m a b - } - - --- | Make an 'OuroborosApplication' for the bundle of mini-protocols that --- make up the overall node-to-client protocol. --- --- This function specifies the wire format protocol numbers as well as the --- protocols that run for each 'NodeToClientVersion'. --- --- They are chosen to not overlap with the node to node protocol numbers. --- This is not essential for correctness, but is helpful to allow a single --- shared implementation of tools that can analyse both protocols, e.g. --- wireshark plugins. --- -nodeToClientProtocols - :: NodeToClientProtocols appType addr bytes m a b - -> NodeToClientVersion - -> NodeToClientVersionData - -> OuroborosApplicationWithMinimalCtx appType addr bytes m a b -nodeToClientProtocols protocols _version _versionData = - OuroborosApplication $ - case protocols of - NodeToClientProtocols { - localChainSyncProtocol, - localTxSubmissionProtocol, - localStateQueryProtocol, - localTxMonitorProtocol - } -> - [ localChainSyncMiniProtocol localChainSyncProtocol - , localTxSubmissionMiniProtocol localTxSubmissionProtocol - , localStateQueryMiniProtocol localStateQueryProtocol - , localTxMonitorMiniProtocol localTxMonitorProtocol - ] - - where - localChainSyncMiniProtocol localChainSyncProtocol = MiniProtocol { - miniProtocolNum = MiniProtocolNum 5, - miniProtocolStart = StartOnDemand, - miniProtocolLimits = maximumMiniProtocolLimits, - miniProtocolRun = localChainSyncProtocol - } - localTxSubmissionMiniProtocol localTxSubmissionProtocol = MiniProtocol { - miniProtocolNum = MiniProtocolNum 6, - miniProtocolStart = StartOnDemand, - miniProtocolLimits = maximumMiniProtocolLimits, - miniProtocolRun = localTxSubmissionProtocol - } - localStateQueryMiniProtocol localStateQueryProtocol = MiniProtocol { - miniProtocolNum = MiniProtocolNum 7, - miniProtocolStart = StartOnDemand, - miniProtocolLimits = maximumMiniProtocolLimits, - miniProtocolRun = localStateQueryProtocol - } - localTxMonitorMiniProtocol localTxMonitorProtocol = MiniProtocol { - miniProtocolNum = MiniProtocolNum 9, - miniProtocolStart = StartOnDemand, - miniProtocolLimits = maximumMiniProtocolLimits, - miniProtocolRun = localTxMonitorProtocol - } - -maximumMiniProtocolLimits :: MiniProtocolLimits -maximumMiniProtocolLimits = - MiniProtocolLimits { - maximumIngressQueue = 0xffffffff - } - - --- | 'Versions' containing a single version of 'nodeToClientProtocols'. --- -versionedNodeToClientProtocols - :: NodeToClientVersion - -> NodeToClientVersionData - -> NodeToClientProtocols appType LocalAddress bytes m a b - -> Versions NodeToClientVersion - NodeToClientVersionData - (OuroborosApplicationWithMinimalCtx appType LocalAddress bytes m a b) -versionedNodeToClientProtocols versionNumber versionData protocols = - simpleSingletonVersions - versionNumber - versionData - (nodeToClientProtocols protocols versionNumber) - --- | A specialised version of 'Ouroboros.Network.Socket.connectToNode'. It is --- a general purpose function which can connect using any version of the --- protocol. This is mostly useful for future enhancements. --- -connectTo - :: LocalSnocket - -- ^ callback constructed by 'Ouroboros.Network.IOManager.withIOManager' - -> NetworkConnectTracers LocalAddress NodeToClientVersion - -> Versions NodeToClientVersion - NodeToClientVersionData - (OuroborosApplicationWithMinimalCtx - Mx.InitiatorMode LocalAddress BL.ByteString IO a Void) - -- ^ A dictionary of protocol versions & applications to run on an established - -- connection. The application to run will be chosen by initial handshake - -- protocol (the highest shared version will be chosen). - -> FilePath - -- ^ path of the unix socket or named pipe - -> IO (Either SomeException a) -connectTo snocket tracers versions path = - fmap fn <$> - connectToNode - snocket - makeLocalBearer - ConnectToArgs { - ctaHandshakeCodec = nodeToClientHandshakeCodec, - ctaHandshakeTimeLimits = noTimeLimitsHandshake, - ctaVersionDataCodec = cborTermVersionDataCodec nodeToClientCodecCBORTerm, - ctaConnectTracers = tracers, - ctaHandshakeCallbacks = HandshakeCallbacks acceptableVersion queryVersion - } - mempty - versions - Nothing - (localAddressFromPath path) - where - fn :: forall x. Either x Void -> x - fn = either id absurd - --- | A version of `connectTo` which exposes `Mx.Mux` interfaces which allows to --- run mini-protocols and handle their termination (e.g. restart them when they --- terminate or error). --- -connectToWithMux - :: LocalSnocket - -- ^ callback constructed by 'Ouroboros.Network.IOManager.withIOManager' - -> NetworkConnectTracers LocalAddress NodeToClientVersion - -> Versions NodeToClientVersion - NodeToClientVersionData - (OuroborosApplicationWithMinimalCtx - Mx.InitiatorMode LocalAddress BL.ByteString IO a b) - -- ^ A dictionary of protocol versions & applications to run on an established - -- connection. The application to run will be chosen by initial handshake - -- protocol (the highest shared version will be chosen). - -> FilePath - -- ^ path of the unix socket or named pipe - -> ( ConnectionId LocalAddress - -> NodeToClientVersion - -> NodeToClientVersionData - -> OuroborosApplicationWithMinimalCtx Mx.InitiatorMode LocalAddress BL.ByteString IO a b - -> Mx.Mux Mx.InitiatorMode IO - -> Async.Async () - -> IO x) - -- ^ callback which has access to negotiated protocols and mux handle created for - -- that connection. The `Async` is a handle the the thread which runs - -- `Mx.runMux`. The `Mux` handle allows schedule mini-protocols. - -- - -- NOTE: when the callback returns or errors, the mux thread will be killed. - -> IO x -connectToWithMux snocket tracers versions path k = - connectToNodeWithMux - snocket - makeLocalBearer - ConnectToArgs { - ctaHandshakeCodec = nodeToClientHandshakeCodec, - ctaHandshakeTimeLimits = noTimeLimitsHandshake, - ctaVersionDataCodec = cborTermVersionDataCodec nodeToClientCodecCBORTerm, - ctaConnectTracers = tracers, - ctaHandshakeCallbacks = HandshakeCallbacks acceptableVersion queryVersion - } - mempty - versions - Nothing - (localAddressFromPath path) - k - - -type LocalConnectionId = ConnectionId LocalAddress - --- --- Null Protocol Peers --- - -chainSyncPeerNull - :: forall (header :: Type) (point :: Type) (tip :: Type) m a. MonadDelay m - => Client (ChainSync.ChainSync header point tip) - NonPipelined ChainSync.StIdle m a -chainSyncPeerNull = - ChainSync.chainSyncClientPeer - (ChainSync.ChainSyncClient untilTheCowsComeHome ) - -localStateQueryPeerNull - :: forall (block :: Type) (point :: Type) (query :: Type -> Type) m a. - MonadDelay m - => Stateful.Client (LocalStateQuery.LocalStateQuery block point query) - LocalStateQuery.StIdle LocalStateQuery.State m a -localStateQueryPeerNull = - LocalStateQuery.localStateQueryClientPeer - (LocalStateQuery.LocalStateQueryClient untilTheCowsComeHome) - -localTxSubmissionPeerNull - :: forall (tx :: Type) (reject :: Type) m a. MonadDelay m - => Client (LocalTxSubmission.LocalTxSubmission tx reject) - NonPipelined LocalTxSubmission.StIdle m a -localTxSubmissionPeerNull = - LocalTxSubmission.localTxSubmissionClientPeer - (LocalTxSubmission.LocalTxSubmissionClient untilTheCowsComeHome) - -localTxMonitorPeerNull - :: forall (txid :: Type) (tx :: Type) (slot :: Type) m a. MonadDelay m - => Client (LocalTxMonitor.LocalTxMonitor txid tx slot) - NonPipelined LocalTxMonitor.StIdle m a -localTxMonitorPeerNull = - LocalTxMonitor.localTxMonitorClientPeer - (LocalTxMonitor.LocalTxMonitorClient untilTheCowsComeHome) - --- ;) -untilTheCowsComeHome :: MonadDelay m => m a -untilTheCowsComeHome = forever $ threadDelay 43200 {- day in seconds -} diff --git a/ouroboros-network/src/Ouroboros/Network/NodeToNode.hs b/ouroboros-network/src/Ouroboros/Network/NodeToNode.hs deleted file mode 100644 index bb6001cc1fd..00000000000 --- a/ouroboros-network/src/Ouroboros/Network/NodeToNode.hs +++ /dev/null @@ -1,440 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE NumericUnderscores #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeFamilies #-} - -{-# OPTIONS_GHC -Wno-orphans #-} - --- | This is the starting point for a module that will bring together the --- overall node to node protocol, as a collection of mini-protocols. --- -module Ouroboros.Network.NodeToNode - ( nodeToNodeProtocols - , NodeToNodeProtocols (..) - , NodeToNodeProtocolsWithExpandedCtx - , NodeToNodeProtocolsWithMinimalCtx - , MiniProtocolParameters (..) - , chainSyncProtocolLimits - , blockFetchProtocolLimits - , txSubmissionProtocolLimits - , keepAliveProtocolLimits - , peerSharingProtocolLimits - , defaultMiniProtocolParameters - , NodeToNodeVersion (..) - , NodeToNodeVersionData (..) - , NetworkConnectTracers (..) - , nullNetworkConnectTracers - , connectTo - , AcceptedConnectionsLimit (..) - , ntnDataFlow - , addSafetyMargin - -- * P2P Governor - , PeerAdvertise (..) - , PeerSelectionTargets (..) - -- * Subscription Workers - -- ** Versions - , Versions (..) - , DiffusionMode (..) - , simpleSingletonVersions - , foldMapVersions - , combineVersions - -- *** Codecs - , nodeToNodeHandshakeCodec - , nodeToNodeVersionCodec - , nodeToNodeCodecCBORTerm - -- * Re-exports - , ExpandedInitiatorContext (..) - , MinimalInitiatorContext (..) - , ResponderContext (..) - , ConnectionId (..) - , ControlMessage (..) - , ControlMessageSTM - , RemoteAddress - , RemoteConnectionId - , IsBigLedgerPeer (..) - , NumTxIdsToAck (..) - , ProtocolLimitFailure - , Handshake - , Socket - -- ** Exceptions - , ExceptionInHandler (..) - -- ** Traces - , AcceptConnectionsPolicyTrace (..) - , TraceSendRecv (..) - , HandshakeTr - -- * For Consensus ThreadNet Tests - , chainSyncMiniProtocolNum - , blockFetchMiniProtocolNum - , txSubmissionMiniProtocolNum - , keepAliveMiniProtocolNum - , peerSharingMiniProtocolNum - ) where - -import Control.Exception (SomeException) - -import Codec.CBOR.Term qualified as CBOR -import Data.ByteString.Lazy qualified as BL -import Data.Word -import Network.Mux qualified as Mx -import Network.Socket (Socket, StructLinger (..)) -import Network.Socket qualified as Socket - -import Ouroboros.Network.ConnectionManager.Types (DataFlow (..), - ExceptionInHandler (..)) -import Ouroboros.Network.Context -import Ouroboros.Network.ControlMessage (ControlMessage (..)) -import Ouroboros.Network.Driver (TraceSendRecv (..)) -import Ouroboros.Network.Driver.Limits (ProtocolLimitFailure (..)) -import Ouroboros.Network.Mux -import Ouroboros.Network.NodeToNode.Version -import Ouroboros.Network.PeerSelection.Governor.Types - (PeerSelectionTargets (..)) -import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise (..)) -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) -import Ouroboros.Network.Protocol.Handshake.Codec -import Ouroboros.Network.Protocol.Handshake.Type -import Ouroboros.Network.Protocol.Handshake.Version hiding (Accept) -import Ouroboros.Network.Protocol.TxSubmission2.Type (NumTxIdsToAck (..)) -import Ouroboros.Network.Server.RateLimiting -import Ouroboros.Network.Snocket -import Ouroboros.Network.Socket -import Ouroboros.Network.Util.ShowProxy (ShowProxy, showProxy) - - --- The Handshake tracer types are simply terrible. -type HandshakeTr ntnAddr ntnVersion = - Mx.WithBearer (ConnectionId ntnAddr) - (TraceSendRecv (Handshake ntnVersion CBOR.Term)) - - -data NodeToNodeProtocols appType initiatorCtx responderCtx bytes m a b = NodeToNodeProtocols { - -- | chain-sync mini-protocol - -- - chainSyncProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b, - - -- | block-fetch mini-protocol - -- - blockFetchProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b, - - -- | tx-submission mini-protocol - -- - txSubmissionProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b, - - -- | keep-alive mini-protocol - -- - keepAliveProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b, - - -- | peer sharing mini-protocol - -- - peerSharingProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b - - } - -type NodeToNodeProtocolsWithExpandedCtx appType ntnAddr bytes m a b = - NodeToNodeProtocols appType (ExpandedInitiatorContext ntnAddr m) (ResponderContext ntnAddr) bytes m a b -type NodeToNodeProtocolsWithMinimalCtx appType ntnAddr bytes m a b = - NodeToNodeProtocols appType (MinimalInitiatorContext ntnAddr) (ResponderContext ntnAddr) bytes m a b - - -data MiniProtocolParameters = MiniProtocolParameters { - chainSyncPipeliningHighMark :: !Word16, - -- ^ high threshold for pipelining (we will never exceed that many - -- messages pipelined). - - chainSyncPipeliningLowMark :: !Word16, - -- ^ low threshold: if we hit the 'chainSyncPipeliningHighMark' we will - -- listen for responses until there are at most - -- 'chainSyncPipeliningLowMark' pipelined message - -- - -- Must be smaller than 'chainSyncPipeliningHighMark'. - -- - -- Note: 'chainSyncPipeliningLowMark' and 'chainSyncPipeliningLowMark' - -- are passed to 'pipelineDecisionLowHighMark'. - - blockFetchPipeliningMax :: !Word16, - -- ^ maximal number of pipelined messages in 'block-fetch' mini-protocol. - - txSubmissionMaxUnacked :: !NumTxIdsToAck - -- ^ maximal number of unacked tx (pipelining is bounded by twice this - -- number) - } - -defaultMiniProtocolParameters :: MiniProtocolParameters -defaultMiniProtocolParameters = MiniProtocolParameters { - chainSyncPipeliningLowMark = 200 - , chainSyncPipeliningHighMark = 300 - , blockFetchPipeliningMax = 100 - , txSubmissionMaxUnacked = 10 - } - --- | Make an 'OuroborosApplication' for the bundle of mini-protocols that --- make up the overall node-to-node protocol. --- --- This function specifies the wire format protocol numbers. --- --- The application specific protocol numbers start from 2. The --- @'MiniProtocolNum' 0@ is reserved for the 'Handshake' protocol, while --- @'MiniProtocolNum' 1@ is reserved for DeltaQ messages. --- 'Handshake' protocol is not included in 'NodeToNodeProtocols' as it runs --- before mux is started but it reusing 'MuxBearer' to send and receive --- messages. Only when the handshake protocol succeeds, we will know which --- protocols to run / multiplex. --- --- These are chosen to not overlap with the node to client protocol numbers (and --- the handshake protocol number). This is not essential for correctness, but --- is helpful to allow a single shared implementation of tools that can analyse --- both protocols, e.g. wireshark plugins. --- -nodeToNodeProtocols - :: MiniProtocolParameters - -> NodeToNodeProtocols muxMode initiatorCtx responderCtx bytes m a b - -> NodeToNodeVersion - -- ^ negotiated version number - -> NodeToNodeVersionData - -- ^ negotiated version data - -> OuroborosBundle muxMode initiatorCtx responderCtx bytes m a b -nodeToNodeProtocols miniProtocolParameters protocols - _version NodeToNodeVersionData { peerSharing } - = - TemperatureBundle - -- Hot protocols: 'chain-sync', 'block-fetch' and 'tx-submission'. - (WithHot $ - case protocols of - NodeToNodeProtocols { chainSyncProtocol, - blockFetchProtocol, - txSubmissionProtocol - } -> - [ MiniProtocol { - miniProtocolNum = chainSyncMiniProtocolNum, - miniProtocolStart = StartOnDemand, - miniProtocolLimits = chainSyncProtocolLimits miniProtocolParameters, - miniProtocolRun = chainSyncProtocol - } - , MiniProtocol { - miniProtocolNum = blockFetchMiniProtocolNum, - miniProtocolStart = StartOnDemand, - miniProtocolLimits = blockFetchProtocolLimits miniProtocolParameters, - miniProtocolRun = blockFetchProtocol - } - , MiniProtocol { - miniProtocolNum = txSubmissionMiniProtocolNum, - miniProtocolStart = StartOnDemand, - miniProtocolLimits = txSubmissionProtocolLimits miniProtocolParameters, - miniProtocolRun = txSubmissionProtocol - } - ]) - - -- Warm protocols: reserved for 'tip-sample'. - (WithWarm []) - - -- Established protocols: 'keep-alive'. - (WithEstablished $ - case protocols of - NodeToNodeProtocols { keepAliveProtocol, - peerSharingProtocol } -> - MiniProtocol { - miniProtocolNum = keepAliveMiniProtocolNum, - miniProtocolStart = StartOnDemandAny, - miniProtocolLimits = keepAliveProtocolLimits miniProtocolParameters, - miniProtocolRun = keepAliveProtocol - } - : case peerSharing of - PeerSharingEnabled -> - [ MiniProtocol { - miniProtocolNum = peerSharingMiniProtocolNum, - miniProtocolStart = StartOnDemand, - miniProtocolLimits = peerSharingProtocolLimits miniProtocolParameters, - miniProtocolRun = peerSharingProtocol - } - ] - PeerSharingDisabled -> - [] - ) - -addSafetyMargin :: Int -> Int -addSafetyMargin x = x + x `div` 10 - -chainSyncProtocolLimits - , blockFetchProtocolLimits - , txSubmissionProtocolLimits - , keepAliveProtocolLimits - , peerSharingProtocolLimits :: MiniProtocolParameters -> MiniProtocolLimits - -chainSyncProtocolLimits MiniProtocolParameters { chainSyncPipeliningHighMark } = - MiniProtocolLimits { - -- The largest message over ChainSync is @MsgRollForward@ which mainly - -- consists of a BlockHeader. - -- TODO: 1400 comes from maxBlockHeaderSize in genesis, but should come - -- from consensus rather than being hard coded. - maximumIngressQueue = addSafetyMargin $ - fromIntegral chainSyncPipeliningHighMark * 1400 - } - -blockFetchProtocolLimits MiniProtocolParameters { blockFetchPipeliningMax } = MiniProtocolLimits { - -- block-fetch client can pipeline at most 'blockFetchPipeliningMax' - -- blocks (currently '10'). This is currently hard coded in - -- 'Ouroboros.Network.BlockFetch.blockFetchLogic' (where - -- @maxInFlightReqsPerPeer = 100@ is specified). In the future the - -- block fetch client will count bytes rather than blocks. By far - -- the largest (and the only pipelined message) in 'block-fetch' - -- protocol is 'MsgBlock'. Current block size limit is 88kiB and - -- `blockFetchPipeliningMax` below is set to `100`. This means that - -- overall queue limit must be: - -- - -- ``` - -- 100 * 88kiB = 8.8MiB - -- ``` - -- - -- In the byron era this limit was set to `10 * 2MiB`, we keep the more - -- relaxed limit here. - -- - maximumIngressQueue = addSafetyMargin $ - max (10 * 2_097_154 :: Int) (fromIntegral blockFetchPipeliningMax * 90_112) - } - -txSubmissionProtocolLimits MiniProtocolParameters { txSubmissionMaxUnacked } = MiniProtocolLimits { - -- tx-submission server can pipeline both 'MsgRequestTxIds' and - -- 'MsgRequestTx'. This means that there can be many - -- 'MsgReplyTxIds', 'MsgReplyTxs' messages in an inbound queue (their - -- sizes are strictly greater than the corresponding request - -- messages). - -- - -- Each 'MsgRequestTx' can contain at max @maxTxIdsToRequest = 3@ - -- (defined in -- 'Ouroboros.Network.TxSubmission.Inbound.txSubmissionInbound') - -- - -- Each 'MsgRequestTx' can request at max @maxTxToRequest = 2@ - -- (defined in -- 'Ouroboros.Network.TxSubmission.Inbound.txSubmissionInbound') - -- - -- The 'txSubmissionInBound' server can at most put `100` - -- unacknowledged transactions. It also pipelines both 'MsgRequestTx` - -- and `MsgRequestTx` in turn. This means that the inbound queue can - -- have at most `100` `MsgRequestTxIds` and `MsgRequestTx` which will - -- contain a single `TxId` / `Tx`. - -- - -- TODO: the unacknowledged transactions are configured in `NodeArgs`, - -- and we should take this parameter as an input for this computation. - -- - -- The upper bound of size of a single transaction is 64k, while the - -- size of `TxId` is `34` bytes (`type TxId = Hash Tx`). - -- - -- Ingress side of `txSubmissinInbound` - -- - -- - 'MsgReplyTxs' carrying a single `TxId`: - -- ``` - -- 1 -- encodeListLen 2 - -- + 1 -- encodeWord 1 - -- + 1 -- encodeListLenIndef - -- + 1 -- encodeListLen 2 - -- + 34 -- encode 'TxId' - -- + 5 -- encodeWord32 (size of tx) - -- + 1 -- encodeBreak - -- = 44 - -- ``` - -- - 'MsgReplyTx' carrying a single 'Tx': - -- ``` - -- 1 -- encodeListLen 2 - -- + 1 -- encodeWord 3 - -- + 1 -- encodeListLenIndef - -- + 65_536 -- 64kiB transaction - -- + 1 -- encodeBreak - -- = 65_540 - -- ``` - -- - -- On the ingress side of 'txSubmissionOutbound' we can have at most - -- `MaxUnacked' 'MsgRequestTxsIds' and the same amount of - -- 'MsgRequsetTx' containing a single 'TxId'. The size of - -- 'MsgRequestTxsIds' is much smaller that 'MsgReplyTx', and the size - -- of `MsgReqeustTx` with a single 'TxId' is smaller than - -- 'MsgReplyTxIds' which contains a single 'TxId' (it just contains - -- the 'TxId' without the size of 'Tx' in bytes). So the ingress - -- queue of 'txSubmissionOutbound' is bounded by the ingress side of - -- the 'txSubmissionInbound' - -- - -- Currently the value of 'txSubmissionMaxUnacked' is '100', for - -- which the upper bound is `100 * (44 + 65_540) = 6_558_400`, we add - -- 10% as a safety margin. - -- - maximumIngressQueue = addSafetyMargin $ - fromIntegral txSubmissionMaxUnacked * (44 + 65_540) - } - -keepAliveProtocolLimits _ = - MiniProtocolLimits { - -- One small outstanding message. - maximumIngressQueue = addSafetyMargin 1280 - } - -peerSharingProtocolLimits _ = - MiniProtocolLimits { - -- This protocol does not need to be pipelined and a peer can only ask - -- for a maximum of 255 peers each time. Hence a reply can have up to - -- 255 IP (IPv4 or IPv6) addresses so 255 * 16 = 4080. TCP has an initial - -- window size of 4 and a TCP segment is 1440, which gives us 4 * 1440 = - -- 5760 bytes to fit into a single RTT. So setting the maximum ingress - -- queue to be a single RTT should be enough to cover for CBOR overhead. - maximumIngressQueue = 4 * 1440 - } - -chainSyncMiniProtocolNum :: MiniProtocolNum -chainSyncMiniProtocolNum = MiniProtocolNum 2 - -blockFetchMiniProtocolNum :: MiniProtocolNum -blockFetchMiniProtocolNum = MiniProtocolNum 3 - -txSubmissionMiniProtocolNum :: MiniProtocolNum -txSubmissionMiniProtocolNum = MiniProtocolNum 4 - -keepAliveMiniProtocolNum :: MiniProtocolNum -keepAliveMiniProtocolNum = MiniProtocolNum 8 - -peerSharingMiniProtocolNum :: MiniProtocolNum -peerSharingMiniProtocolNum = MiniProtocolNum 10 - --- | A specialised version of @'Ouroboros.Network.Socket.connectToNode'@. --- -connectTo - :: Snocket IO Socket.Socket Socket.SockAddr - -> NetworkConnectTracers Socket.SockAddr NodeToNodeVersion - -> Versions NodeToNodeVersion - NodeToNodeVersionData - (OuroborosApplicationWithMinimalCtx - Mx.InitiatorMode Socket.SockAddr BL.ByteString IO a b) - -> Maybe Socket.SockAddr - -> Socket.SockAddr - -> IO (Either SomeException (Either a b)) -connectTo sn tr = - connectToNode sn makeSocketBearer - ConnectToArgs { - ctaHandshakeCodec = nodeToNodeHandshakeCodec, - ctaHandshakeTimeLimits = timeLimitsHandshake, - ctaVersionDataCodec = cborTermVersionDataCodec nodeToNodeCodecCBORTerm, - ctaConnectTracers = tr, - ctaHandshakeCallbacks = HandshakeCallbacks acceptableVersion queryVersion - } - configureOutboundSocket - where - configureOutboundSocket :: Socket -> IO () - configureOutboundSocket sock = do - Socket.setSocketOption sock Socket.NoDelay 1 - Socket.setSockOpt sock Socket.Linger - (StructLinger { sl_onoff = 1, - sl_linger = 0 }) - --- | Node-To-Node protocol connections which negotiated --- `InitiatorAndResponderDiffusionMode` are `Duplex`. --- -ntnDataFlow :: NodeToNodeVersionData -> DataFlow -ntnDataFlow NodeToNodeVersionData { diffusionMode } = - case diffusionMode of - InitiatorAndResponderDiffusionMode -> Duplex - InitiatorOnlyDiffusionMode -> Unidirectional - -type RemoteAddress = Socket.SockAddr - -instance ShowProxy RemoteAddress where - showProxy _ = "SockAddr" - -type RemoteConnectionId = ConnectionId RemoteAddress From 603092e4a6612eed42a9f05e14b4e6dce4b37196 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Mon, 15 Sep 2025 17:02:03 +0200 Subject: [PATCH 02/24] Moved ouroboros-network-protocols to ouroboros-network * `ouroboros-network-protocols` -> `ouroboros-network:protocols` in `protocols/lib` * `ouroboros-network-protocols:testlib` -> `ouroboros-network:protocols-tests-lib` in `protocols/tests-lib` * `ouroboros-network-protocols:test` -> `ouroboros-network:protocols-tests` in `protocols/tests` * `ouroboros-network-protocols:bench` -> `ouroboros-network:protocols-bench` in `protocols/bench` --- cabal.project | 1 - dmq-node/dmq-node.cabal | 5 +- ouroboros-network-protocols/CHANGELOG.md | 274 --------------- ouroboros-network-protocols/LICENSE | 177 ---------- ouroboros-network-protocols/NOTICE | 14 - .../changelog.d/scriv.ini | 15 - .../ouroboros-network-protocols.cabal | 315 ------------------ ouroboros-network/changelog.d/scriv.ini | 15 - ouroboros-network/ouroboros-network.cabal | 292 +++++++++++++++- .../protocols/bench}/Main.hs | 0 .../protocols}/cddl/Main.hs | 16 +- .../protocols}/cddl/specs/block-fetch.cddl | 0 .../protocols}/cddl/specs/chain-sync.cddl | 0 .../cddl/specs/handshake-node-to-client.cddl | 0 .../specs/handshake-node-to-node-v14.cddl | 0 .../protocols}/cddl/specs/keep-alive.cddl | 0 .../cddl/specs/local-state-query.cddl | 0 .../cddl/specs/local-tx-monitor.cddl | 0 .../cddl/specs/local-tx-submission.cddl | 0 .../protocols}/cddl/specs/network.base.cddl | 0 .../specs/node-to-node-version-data-v14.cddl | 0 .../handshake-node-to-node-v11-12.cddl | 0 .../obsolete/handshake-node-to-node-v13.cddl | 0 .../obsolete/handshake-node-to-node.cddl | 0 .../node-to-node-version-data-v11-12.cddl | 0 .../node-to-node-version-data-v13.cddl | 0 .../obsolete/node-to-node-version-data.cddl | 0 .../specs/obsolete/peer-sharing-v11-12.cddl | 0 .../cddl/specs/obsolete/peer-sharing-v13.cddl | 0 .../cddl/specs/peer-sharing-v14.cddl | 0 .../protocols}/cddl/specs/tx-submission2.cddl | 0 .../Network/Protocol/BlockFetch/Client.hs | 0 .../Network/Protocol/BlockFetch/Codec.hs | 0 .../Network/Protocol/BlockFetch/Server.hs | 0 .../Network/Protocol/BlockFetch/Type.hs | 0 .../Network/Protocol/ChainSync/Client.hs | 0 .../Protocol/ChainSync/ClientPipelined.hs | 0 .../Network/Protocol/ChainSync/Codec.hs | 0 .../Protocol/ChainSync/PipelineDecision.hs | 0 .../Network/Protocol/ChainSync/Server.hs | 0 .../Network/Protocol/ChainSync/Type.hs | 0 .../Ouroboros/Network/Protocol/Codec/Utils.hs | 0 .../Network/Protocol/KeepAlive/Client.hs | 0 .../Network/Protocol/KeepAlive/Codec.hs | 0 .../Network/Protocol/KeepAlive/Server.hs | 0 .../Network/Protocol/KeepAlive/Type.hs | 0 .../Protocol/LocalStateQuery/Client.hs | 0 .../Network/Protocol/LocalStateQuery/Codec.hs | 0 .../Protocol/LocalStateQuery/Server.hs | 0 .../Network/Protocol/LocalStateQuery/Type.hs | 0 .../Network/Protocol/LocalTxMonitor/Client.hs | 0 .../Network/Protocol/LocalTxMonitor/Codec.hs | 0 .../Network/Protocol/LocalTxMonitor/Server.hs | 0 .../Network/Protocol/LocalTxMonitor/Type.hs | 0 .../Protocol/LocalTxSubmission/Client.hs | 0 .../Protocol/LocalTxSubmission/Codec.hs | 0 .../Protocol/LocalTxSubmission/Server.hs | 0 .../Protocol/LocalTxSubmission/Type.hs | 0 .../Network/Protocol/PeerSharing/Client.hs | 0 .../Network/Protocol/PeerSharing/Codec.hs | 0 .../Network/Protocol/PeerSharing/Server.hs | 0 .../Network/Protocol/PeerSharing/Type.hs | 0 .../Network/Protocol/TxSubmission2/Client.hs | 0 .../Network/Protocol/TxSubmission2/Codec.hs | 0 .../Network/Protocol/TxSubmission2/Server.hs | 0 .../Network/Protocol/TxSubmission2/Type.hs | 0 .../Network/Protocol/BlockFetch/Codec/CDDL.hs | 0 .../Network/Protocol/BlockFetch/Direct.hs | 0 .../Network/Protocol/BlockFetch/Examples.hs | 0 .../Network/Protocol/BlockFetch/Test.hs | 0 .../Network/Protocol/ChainSync/Codec/CDDL.hs | 0 .../Network/Protocol/ChainSync/Direct.hs | 0 .../Protocol/ChainSync/DirectPipelined.hs | 0 .../Network/Protocol/ChainSync/Examples.hs | 2 - .../Protocol/ChainSync/ExamplesPipelined.hs | 0 .../Network/Protocol/ChainSync/Test.hs | 11 +- .../Network/Protocol/Handshake/Direct.hs | 0 .../Network/Protocol/Handshake/Test.hs | 19 +- .../Network/Protocol/KeepAlive/Direct.hs | 0 .../Network/Protocol/KeepAlive/Examples.hs | 0 .../Network/Protocol/KeepAlive/Test.hs | 2 - .../Protocol/LocalStateQuery/Codec/CDDL.hs | 0 .../Protocol/LocalStateQuery/Direct.hs | 0 .../Protocol/LocalStateQuery/Examples.hs | 0 .../Network/Protocol/LocalStateQuery/Test.hs | 3 +- .../Protocol/LocalTxMonitor/Codec/CDDL.hs | 0 .../Network/Protocol/LocalTxMonitor/Direct.hs | 0 .../Protocol/LocalTxMonitor/Examples.hs | 0 .../Network/Protocol/LocalTxMonitor/Test.hs | 0 .../Protocol/LocalTxSubmission/Codec/CDDL.hs | 0 .../Protocol/LocalTxSubmission/Direct.hs | 0 .../Protocol/LocalTxSubmission/Examples.hs | 0 .../Protocol/LocalTxSubmission/Test.hs | 0 .../Protocol/PeerSharing/Codec/CDDL.hs | 0 .../Network/Protocol/PeerSharing/Direct.hs | 0 .../Network/Protocol/PeerSharing/Examples.hs | 0 .../Network/Protocol/PeerSharing/Test.hs | 0 .../Protocol/TxSubmission2/Codec/CDDL.hs | 0 .../Network/Protocol/TxSubmission2/Direct.hs | 0 .../Protocol/TxSubmission2/Examples.hs | 0 .../Network/Protocol/TxSubmission2/Test.hs | 0 .../tests-lib}/Test/ChainGenerators.hs | 0 .../tests-lib}/Test/ChainProducerState.hs | 2 +- .../protocols/tests-lib}/Test/Data/CDDL.hs | 0 .../tests-lib}/Test/Data/PipeliningDepth.hs | 0 .../Test/Ouroboros/Network/Protocol/Utils.hs | 0 .../protocols/tests}/Main.hs | 0 .../protocols/tests}/Test/AnchoredFragment.hs | 0 .../protocols/tests}/Test/Chain.hs | 0 109 files changed, 296 insertions(+), 867 deletions(-) delete mode 100644 ouroboros-network-protocols/CHANGELOG.md delete mode 100644 ouroboros-network-protocols/LICENSE delete mode 100644 ouroboros-network-protocols/NOTICE delete mode 100644 ouroboros-network-protocols/changelog.d/scriv.ini delete mode 100644 ouroboros-network-protocols/ouroboros-network-protocols.cabal delete mode 100644 ouroboros-network/changelog.d/scriv.ini rename {ouroboros-network-protocols/bench-cddl => ouroboros-network/protocols/bench}/Main.hs (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/Main.hs (98%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/block-fetch.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/chain-sync.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/handshake-node-to-client.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/handshake-node-to-node-v14.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/keep-alive.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/local-state-query.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/local-tx-monitor.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/local-tx-submission.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/network.base.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/node-to-node-version-data-v14.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/obsolete/handshake-node-to-node-v13.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/obsolete/handshake-node-to-node.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/obsolete/node-to-node-version-data-v13.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/obsolete/node-to-node-version-data.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/obsolete/peer-sharing-v11-12.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/obsolete/peer-sharing-v13.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/peer-sharing-v14.cddl (100%) rename {ouroboros-network-protocols => ouroboros-network/protocols}/cddl/specs/tx-submission2.cddl (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/BlockFetch/Client.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/BlockFetch/Codec.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/BlockFetch/Server.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/BlockFetch/Type.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/ChainSync/Client.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/ChainSync/ClientPipelined.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/ChainSync/Codec.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/ChainSync/PipelineDecision.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/ChainSync/Server.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/ChainSync/Type.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/Codec/Utils.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/KeepAlive/Client.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/KeepAlive/Codec.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/KeepAlive/Server.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/KeepAlive/Type.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalStateQuery/Client.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalStateQuery/Server.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalTxMonitor/Server.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalTxSubmission/Client.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalTxSubmission/Codec.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalTxSubmission/Server.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/LocalTxSubmission/Type.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/PeerSharing/Client.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/PeerSharing/Codec.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/PeerSharing/Server.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/PeerSharing/Type.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/TxSubmission2/Client.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/TxSubmission2/Codec.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/TxSubmission2/Server.hs (100%) rename {ouroboros-network-protocols/src => ouroboros-network/protocols/lib}/Ouroboros/Network/Protocol/TxSubmission2/Type.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/BlockFetch/Codec/CDDL.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/BlockFetch/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/BlockFetch/Examples.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/BlockFetch/Test.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/ChainSync/Codec/CDDL.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/ChainSync/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/ChainSync/DirectPipelined.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/ChainSync/Examples.hs (99%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/ChainSync/ExamplesPipelined.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/ChainSync/Test.hs (99%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/Handshake/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/Handshake/Test.hs (99%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/KeepAlive/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/KeepAlive/Examples.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/KeepAlive/Test.hs (98%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalStateQuery/Codec/CDDL.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalStateQuery/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalStateQuery/Examples.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs (99%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalTxMonitor/Examples.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalTxSubmission/Codec/CDDL.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalTxSubmission/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalTxSubmission/Examples.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/LocalTxSubmission/Test.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/PeerSharing/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/PeerSharing/Examples.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/PeerSharing/Test.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/TxSubmission2/Codec/CDDL.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/TxSubmission2/Direct.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/TxSubmission2/Examples.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Ouroboros/Network/Protocol/TxSubmission2/Test.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Test/ChainGenerators.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Test/ChainProducerState.hs (99%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Test/Data/CDDL.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Test/Data/PipeliningDepth.hs (100%) rename {ouroboros-network-protocols/testlib => ouroboros-network/protocols/tests-lib}/Test/Ouroboros/Network/Protocol/Utils.hs (100%) rename {ouroboros-network-protocols/test => ouroboros-network/protocols/tests}/Main.hs (100%) rename {ouroboros-network-protocols/test => ouroboros-network/protocols/tests}/Test/AnchoredFragment.hs (100%) rename {ouroboros-network-protocols/test => ouroboros-network/protocols/tests}/Test/Chain.hs (100%) diff --git a/cabal.project b/cabal.project index 28096e3a171..d509ab50665 100644 --- a/cabal.project +++ b/cabal.project @@ -27,7 +27,6 @@ packages: ./cardano-ping ./ouroboros-network-api ./ouroboros-network-framework ./ouroboros-network-mock - ./ouroboros-network-protocols ./ouroboros-network-testing ./ntp-client ./cardano-client diff --git a/dmq-node/dmq-node.cabal b/dmq-node/dmq-node.cabal index 65d75e68646..bd5ede309f2 100644 --- a/dmq-node/dmq-node.cabal +++ b/dmq-node/dmq-node.cabal @@ -103,10 +103,9 @@ library network ^>=3.2.7, network-mux ^>=0.9.1, optparse-applicative ^>=0.18, - ouroboros-network:{ouroboros-network, orphan-instances} ^>=0.23, + ouroboros-network:{ouroboros-network, orphan-instances, protocols} ^>=0.23, ouroboros-network-api ^>=0.17, ouroboros-network-framework ^>=0.20, - ouroboros-network-protocols ^>=0.16, random ^>=1.2, singletons, text >=1.2.4 && <2.2, @@ -174,9 +173,9 @@ test-suite dmq-test io-classes, io-sim, kes-agent-crypto, + ouroboros-network:{protocols, protocols-tests-lib}, ouroboros-network-api, ouroboros-network-framework, - ouroboros-network-protocols:{ouroboros-network-protocols, testlib}, ouroboros-network-testing, quickcheck-instances, serialise, diff --git a/ouroboros-network-protocols/CHANGELOG.md b/ouroboros-network-protocols/CHANGELOG.md deleted file mode 100644 index a3fe411340b..00000000000 --- a/ouroboros-network-protocols/CHANGELOG.md +++ /dev/null @@ -1,274 +0,0 @@ -# ouroboros-network-protocols changelog - - - - -## 0.16.0.0 -- 2025-09-10 - -### Breaking changes - -* Generalised `CoolectPipelined` constructor for `TxSubmission2.Server` to allow - running a monadic action in the continuation when no message is available. -* `SendMsgRequestTxsPipelined` constructor for `TxSubmission2.Server` was modified: - now it takes a mpa of txids to sizes instead of a list of txids. - -### Non-breaking changes - -* Added annoteded codec for `TxSubmission2` mini-protocol. -* Added annoteded codec for `LocalTxSubmission` mini-protocol. -* Added `Ouroboros.Network.Protocols.Codec.Utils` module with utility function - for writing annotated codecs. - -## 0.15.0.0 -- 28.06.2025 - -### Breaking changes - -* Chain-sync protocol is providing `ProtocolTimeLimitsWithRnd`. It now must be - run using either `runPeerWithLimitsRnd` or `runPipelinedPeerWithLimitsRnd`. -* `ChainSyncTimeout` data type is removed. -* `timeLimitsChainSync` changed type: it is a function which takes the idle timeout as an argument. -* `Ouroboros.Network.Protocols.TxSubmission2.Codec.{encode,decode}TxSubmission2` - are no longer exported. -* `CollectPipelined` constructor for `TxSubmission2.Server` was modified: now - one can run a monadic action in the continuation when no message is available. - -### Non-breaking changes - -* Improved haddocks of `node-to-node` mini-protocol codecs. - -## 0.14.0.2 -- 2025-07-17 - -### Breaking changes - -### Non-breaking changes - -* loosen upper bound for QuickCheck to <2.16 - -## 0.14.0.1 -- 2025-05-13 - -### Breaking changes - -### Non-breaking changes - -* Adapt to buffered socket bearers from network-mux 0.8 - -## 0.14.0.0 -- 2025-02-25 - -### Breaking changes - -* Adapt the `versionNumber` cddl definition to account for `NodeToClientVersionV20`. -* Added kind signatures to protocol types: - * `ChainSync`, - * `BlockFetch`, - * `TxSubmission2`, - * `PeerSharing`, - * `LocalTxMonitor`, - * `LocalTxSubmission`. - -* Added new `GetMeasures` message to `LocalTxMonitor` - -### Non-breaking changes - -## 0.13.0.0 -- 2025-01-02 - -### Breaking changes - -* Removed deprecated API - -## 0.12.0.0 -- 2024-10-17 - -### Breaking changes - -* Renamed `Test.Ouroboros.Network.Testing.Utils -> Test.Ouroboros.Network.Protocol.Utils` -* Removed deprecated APIs: - * `chainSyncClientNull` - * `localStateQueryClientNull` - * `localTxSubmissionClientNull` - * `TxSizeInBytes` -* Use `typed-protocols-0.3.0.0`. - -### Non-breaking changes - -* Addapted to `network-mux` changes in https://github.com/IntersectMBO/ouroboros-network/pull/4997 - -## 0.11.0.0 -- 2024-10-11 - -### Breaking changes - -* Adapt the `versionNumber` cddl definition to account for `NodeToClientV_18`. - -## 0.10.0.2 -- 2024-08-27 - -### Breaking changes - -### Non-breaking changes - -* bump for bad ref in chap for 0.10.0.1 - -## 0.10.0.1 -- 2024-08-22 - -### Breaking changes - -### Non-breaking changes - -* version bump for build-deps - -## 0.10.0.0 -- 2024-08-07 - -### Breaking changes - -* Use `SizeInBytes` newtype instead of the `TxSizeInBytes` type alias. - `TxSizeInBytes` is now deprecated. - NumTxIdsToAck -* Use `NumTxIdsToAck` newtype wrapper for number of unacked txid's - in `txSubmissionInbound` and `txSubmissionOutbound` - -## 0.9.0.0 -- 2024-06-07 - -### Breaking changes - -* Un-orphan `ShowProxy SlotNo` instance. - -### Non-Breaking changes - -* Bump io-sim and io-classes -* Added a test for `AnchoredFragment.splitAtSlot`. -* Make it build with ghc-9.10 -* Improved memory foot print of tests - -## 0.8.1.0 -- 2024-03-14 - -### Breaking changes - -### Non-Breaking changes - -* Refactored CBOR mini-protocols codecs to a more modular structure -* Added `deepseq` dependency and implemented `NFData` for `testlib` types. -* Added miniprotocols codec benchmarks - -## 0.8.0.0 -- 2024-02-21 - -### Breaking changes - -* Add side-effect argument to `SendMsgRequestNextPipelined` to be invoked - promptly upon `MsgAwaitReply`. - -* Change the arguments of both `SendMsgRequestNext` constructors to have the - same shape (and limited expressivity) as does `SendMsgRequestNextPipelined` - (since we never use the extra expressivity). - -### Non-breaking changes - -## 0.7.0.0 -- 2024-01-22 - -### Breaking changes - -* Pipeline depth type changed from `Word32` to `Word16`. - -* In LocalStateQuery, changed the argument of `MsgAcquire` and `MsgReAcquire` - from `Maybe point` to a new ADT `Target point`. It still allows the client to - acquire either the volatile tip or a specific point, but now also allows them - to instead acquire the immutable tip. - -### Non-breaking changes - -* ghc-9.8 support. - -## 0.6.1.0 -- 2023-12-14 - -### Non-breaking changes - -* Testlib depends on `cardano-slotting`'s `testlib` at version - `0.1.2.0` and uses its instances. - -* Use `io-sim-1.3.1.0`. - -## 0.6.0.1 -- 2023-11-16 - -### Non-breaking changes - -* Use `io-sim-1.3.0.0`. - -## 0.6.0.0 -- 2023-11-02 - -### Breaking changes - -* Make chainsync idle timeout configurable. - -### Non-breaking changes - -* Make it possible for KeepAlive client to collect a rtt sample for the first packet. - -## 0.5.3.0 -- 2023-10-26 - -### Non-breaking changes - -* Improved cdd specs by using `any` (PR #4638) -* Added a 3673s timeout to chainsync's StIdle state. -* Added a 97s timeout to keepalive's StClient state. - -* Added a test to check that Peer Sharing values after handshake are symmetric - relative to the initiator and responder side. -* Added cddl specs and tests for `NodeToNodeV_13` and handshake - -* Refactored cddl tests for `PeerSharing` to take into account versioning. - -## 0.5.2.0 -- 2023-09-08 - -### Non-breaking changes - -* Use `io-classes-1.2`. -* Fixed a momory leak in `GHC-9.2`. - -## 0.5.1.0 -- 2023-07-17 - -### Breaking changes - -* Provide `Any` type in `Test.Data.CDDL` module. -* Definition of `TxId` has changed, it's now a newtype wrapper for - `Any` type, which indicates that `ouroboros-network` does not specify what - `TxId` or `Tx` types are. - -## 0.5.0.3 -- 2023-05-26 - -* `ghc-9.6` compatibility - -## 0.5.0.2 -- 2023-05-15 - -## Non-breaking changes - -* Updated to use `ouroboros-network-api-0.5.0.0`. - -## 0.5.0.1 -- 2023-05-08 - -## Non-breaking changes - -* Updated to use `ouroboros-network-api-0.4.0.0`. - -## 0.5.0.0 -- 2023-04-28 - -### Breaking changes - -* `io-classes-1.1` support. - -### Non-breaking changes - -* `ghc-9.4` and `ghc-9.6` compatibility. - -## 0.4.0.0 -- 2023-04-19 - -- Release - -## 0.3.0.0 -- 2023-02-24 - -### Breaking - -* Modified type `chain-sync` `Client`: `points` method now returns `Either` (PR #4385) - -### Non-Breaking - -* Expanded documentation about CDDL (PR #4351) - -## 0.1.0.0 -- 2022-11-17 - -* Initial release diff --git a/ouroboros-network-protocols/LICENSE b/ouroboros-network-protocols/LICENSE deleted file mode 100644 index f433b1a53f5..00000000000 --- a/ouroboros-network-protocols/LICENSE +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/ouroboros-network-protocols/NOTICE b/ouroboros-network-protocols/NOTICE deleted file mode 100644 index 3efdc24424e..00000000000 --- a/ouroboros-network-protocols/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/ouroboros-network-protocols/changelog.d/scriv.ini b/ouroboros-network-protocols/changelog.d/scriv.ini deleted file mode 100644 index 95cf69a6f69..00000000000 --- a/ouroboros-network-protocols/changelog.d/scriv.ini +++ /dev/null @@ -1,15 +0,0 @@ -[scriv] -format = md -insert_marker = Changelog entries -md_header_level = 2 -version = literal: ouroboros-network-protocols.cabal: version -categories = Breaking, Non-Breaking -start_marker = scriv-insert-here -end_marker = scriv-end-here -fragment_directory = changelog.d -ghrel_template = {{body}} -main_branches = main -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = CHANGELOG.${config:format} -skip_fragments = README.* -entry_title_template = {%% if version %%}{{ version }} -- {%% endif %%}{{ date.strftime('%%Y-%%m-%%d') }} diff --git a/ouroboros-network-protocols/ouroboros-network-protocols.cabal b/ouroboros-network-protocols/ouroboros-network-protocols.cabal deleted file mode 100644 index a3e81f74ba9..00000000000 --- a/ouroboros-network-protocols/ouroboros-network-protocols.cabal +++ /dev/null @@ -1,315 +0,0 @@ -cabal-version: 3.0 -name: ouroboros-network-protocols -version: 0.16.0.0 -synopsis: Ouroboros Network Protocols -description: Ouroboros Network Protocols. -license: Apache-2.0 -license-files: - LICENSE - NOTICE - -copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect -author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts -maintainer: marcin.szamotulski@iohk.io -category: Network -build-type: Simple -extra-doc-files: CHANGELOG.md - -flag asserts - description: Enable assertions - manual: False - default: False - -flag cddl - description: Enable CDDL based tests of the CBOR encoding - manual: True - -- These tests need the cddl and the cbor-diag Ruby-package - default: True - -source-repository head - type: git - location: https://github.com/intersectmbo/ouroboros-network - -library - hs-source-dirs: src - -- At this experiment/prototype stage everything is exposed. - -- This has to be tidied up once the design becomes clear. - exposed-modules: - Ouroboros.Network.Protocol.BlockFetch.Client - Ouroboros.Network.Protocol.BlockFetch.Codec - Ouroboros.Network.Protocol.BlockFetch.Server - Ouroboros.Network.Protocol.BlockFetch.Type - Ouroboros.Network.Protocol.ChainSync.Client - Ouroboros.Network.Protocol.ChainSync.ClientPipelined - Ouroboros.Network.Protocol.ChainSync.Codec - Ouroboros.Network.Protocol.ChainSync.PipelineDecision - Ouroboros.Network.Protocol.ChainSync.Server - Ouroboros.Network.Protocol.ChainSync.Type - Ouroboros.Network.Protocol.Codec.Utils - Ouroboros.Network.Protocol.KeepAlive.Client - Ouroboros.Network.Protocol.KeepAlive.Codec - Ouroboros.Network.Protocol.KeepAlive.Server - Ouroboros.Network.Protocol.KeepAlive.Type - Ouroboros.Network.Protocol.LocalStateQuery.Client - Ouroboros.Network.Protocol.LocalStateQuery.Codec - Ouroboros.Network.Protocol.LocalStateQuery.Server - Ouroboros.Network.Protocol.LocalStateQuery.Type - Ouroboros.Network.Protocol.LocalTxMonitor.Client - Ouroboros.Network.Protocol.LocalTxMonitor.Codec - Ouroboros.Network.Protocol.LocalTxMonitor.Server - Ouroboros.Network.Protocol.LocalTxMonitor.Type - Ouroboros.Network.Protocol.LocalTxSubmission.Client - Ouroboros.Network.Protocol.LocalTxSubmission.Codec - Ouroboros.Network.Protocol.LocalTxSubmission.Server - Ouroboros.Network.Protocol.LocalTxSubmission.Type - Ouroboros.Network.Protocol.PeerSharing.Client - Ouroboros.Network.Protocol.PeerSharing.Codec - Ouroboros.Network.Protocol.PeerSharing.Server - Ouroboros.Network.Protocol.PeerSharing.Type - Ouroboros.Network.Protocol.TxSubmission2.Client - Ouroboros.Network.Protocol.TxSubmission2.Codec - Ouroboros.Network.Protocol.TxSubmission2.Server - Ouroboros.Network.Protocol.TxSubmission2.Type - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - other-extensions: - BangPatterns - DataKinds - EmptyCase - ExistentialQuantification - FlexibleContexts - FlexibleInstances - FunctionalDependencies - GADTSyntax - GADTs - GeneralizedNewtypeDeriving - MultiParamTypeClasses - NamedFieldPuns - OverloadedStrings - PolyKinds - RankNTypes - RecordWildCards - ScopedTypeVariables - TemplateHaskell - TupleSections - TypeApplications - TypeFamilies - TypeInType - - build-depends: - base >=4.14 && <4.22, - bytestring >=0.10 && <0.13, - cborg >=0.2.1 && <0.3, - constraints, - containers, - deepseq, - io-classes:{io-classes, si-timers} ^>=1.8.0.1, - nothunks, - ouroboros-network-api ^>=0.17, - quiet, - random, - serialise, - singletons, - text, - typed-protocols:{typed-protocols, cborg, stateful, stateful-cborg} ^>=1.1, - - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wunused-packages - - if flag(asserts) - ghc-options: -fno-ignore-asserts - -library testlib - visibility: public - hs-source-dirs: testlib - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - exposed-modules: - Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL - Ouroboros.Network.Protocol.BlockFetch.Direct - Ouroboros.Network.Protocol.BlockFetch.Examples - Ouroboros.Network.Protocol.BlockFetch.Test - Ouroboros.Network.Protocol.ChainSync.Codec.CDDL - Ouroboros.Network.Protocol.ChainSync.Direct - Ouroboros.Network.Protocol.ChainSync.DirectPipelined - Ouroboros.Network.Protocol.ChainSync.Examples - Ouroboros.Network.Protocol.ChainSync.ExamplesPipelined - Ouroboros.Network.Protocol.ChainSync.Test - Ouroboros.Network.Protocol.Handshake.Direct - Ouroboros.Network.Protocol.Handshake.Test - Ouroboros.Network.Protocol.KeepAlive.Direct - Ouroboros.Network.Protocol.KeepAlive.Examples - Ouroboros.Network.Protocol.KeepAlive.Test - Ouroboros.Network.Protocol.LocalStateQuery.Codec.CDDL - Ouroboros.Network.Protocol.LocalStateQuery.Direct - Ouroboros.Network.Protocol.LocalStateQuery.Examples - Ouroboros.Network.Protocol.LocalStateQuery.Test - Ouroboros.Network.Protocol.LocalTxMonitor.Codec.CDDL - Ouroboros.Network.Protocol.LocalTxMonitor.Direct - Ouroboros.Network.Protocol.LocalTxMonitor.Examples - Ouroboros.Network.Protocol.LocalTxMonitor.Test - Ouroboros.Network.Protocol.LocalTxSubmission.Codec.CDDL - Ouroboros.Network.Protocol.LocalTxSubmission.Direct - Ouroboros.Network.Protocol.LocalTxSubmission.Examples - Ouroboros.Network.Protocol.LocalTxSubmission.Test - Ouroboros.Network.Protocol.PeerSharing.Codec.CDDL - Ouroboros.Network.Protocol.PeerSharing.Direct - Ouroboros.Network.Protocol.PeerSharing.Examples - Ouroboros.Network.Protocol.PeerSharing.Test - Ouroboros.Network.Protocol.TxSubmission2.Codec.CDDL - Ouroboros.Network.Protocol.TxSubmission2.Direct - Ouroboros.Network.Protocol.TxSubmission2.Examples - Ouroboros.Network.Protocol.TxSubmission2.Test - Test.ChainGenerators - Test.ChainProducerState - Test.Data.CDDL - Test.Data.PipeliningDepth - Test.Ouroboros.Network.Protocol.Utils - - build-depends: - QuickCheck, - base >=4.14 && <4.22, - bytestring, - cardano-slotting:testlib ^>=0.2.0, - cardano-strict-containers, - cborg, - containers, - contra-tracer, - deepseq, - io-classes:{io-classes, si-timers, strict-stm}, - io-sim, - network, - network-mux, - ouroboros-network-api, - ouroboros-network-framework, - ouroboros-network-mock, - ouroboros-network-protocols, - ouroboros-network-testing, - pipes, - quickcheck-instances, - serialise, - tasty, - tasty-quickcheck, - text, - typed-protocols:{typed-protocols, codec-properties, stateful}, - - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wunused-packages - -test-suite test - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Main.hs - -- TODO: these two tests should be moved to `ouroboros-network-mock` - other-modules: - Test.AnchoredFragment - Test.Chain - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - build-depends: - QuickCheck ^>=2.16, - base >=4.14 && <4.22, - ouroboros-network-api, - ouroboros-network-mock, - ouroboros-network-protocols:testlib, - ouroboros-network-testing ^>=0.8, - tasty, - tasty-quickcheck, - - ghc-options: - -threaded - -Wall - -Wunused-packages - -rtsopts - -test-suite cddl - type: exitcode-stdio-1.0 - hs-source-dirs: cddl - main-is: Main.hs - - if flag(cddl) - buildable: True - else - buildable: False - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - build-depends: - QuickCheck, - base >=4.14 && <4.22, - bytestring, - cborg, - containers, - directory, - filepath, - mtl, - network, - ouroboros-network-api, - ouroboros-network-framework, - ouroboros-network-mock, - ouroboros-network-protocols, - ouroboros-network-protocols:testlib, - process-extras, - quickcheck-instances, - serialise, - tasty, - tasty-hunit, - tasty-quickcheck, - temporary, - text, - typed-protocols:{typed-protocols, stateful}, - - ghc-options: - -threaded - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wunused-packages - -rtsopts - -with-rtsopts=-M400m - -test-suite bench - type: exitcode-stdio-1.0 - default-extensions: ImportQualifiedPost - hs-source-dirs: bench-cddl - main-is: Main.hs - default-language: Haskell2010 - build-depends: - base >=4.14 && <4.22, - bytestring, - cborg, - containers, - deepseq, - network, - ouroboros-network-api, - ouroboros-network-framework, - ouroboros-network-protocols, - ouroboros-network-protocols:testlib, - tasty-bench, - typed-protocols:{typed-protocols, stateful}, - - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wunused-packages - -rtsopts - -with-rtsopts=-A32m - -with-rtsopts=-T - - -- Important for comparing benchmarks results against a baseline run. - -- Read: https://hackage.haskell.org/package/tasty-bench for details - if impl(ghc >=8.6) - ghc-options: -fproc-alignment=64 diff --git a/ouroboros-network/changelog.d/scriv.ini b/ouroboros-network/changelog.d/scriv.ini deleted file mode 100644 index 01e1dad40a4..00000000000 --- a/ouroboros-network/changelog.d/scriv.ini +++ /dev/null @@ -1,15 +0,0 @@ -[scriv] -format = md -insert_marker = Changelog entries -md_header_level = 2 -version = literal: ouroboros-network.cabal: version -categories = Breaking, Non-Breaking -start_marker = scriv-insert-here -end_marker = scriv-end-here -fragment_directory = changelog.d -ghrel_template = {{body}} -main_branches = main -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = CHANGELOG.${config:format} -skip_fragments = README.* -entry_title_template = {%% if version %%}{{ version }} -- {%% endif %%}{{ date.strftime('%%Y-%%m-%%d') }} diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 694b832bacb..79b9b49cbdd 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -20,6 +20,12 @@ flag asserts manual: False default: False +flag cddl + description: Enable CDDL based tests of the CBOR encoding + manual: True + -- These tests need the cddl and the cbor-diag Ruby-package + default: True + source-repository head type: git location: https://github.com/intersectmbo/ouroboros-network @@ -158,9 +164,9 @@ library network ^>=3.2.7, network-mux, nothunks, + ouroboros-network:protocols ^>=0.23, ouroboros-network-api ^>=0.17, ouroboros-network-framework ^>=0.20, - ouroboros-network-protocols ^>=0.16, psqueues >=0.2.3 && <0.3, random, strict-checked-vars ^>=0.2, @@ -219,9 +225,9 @@ library orphan-instances network, network-mux, ouroboros-network:{ouroboros-network, cardano-diffusion}, + ouroboros-network:protocols, ouroboros-network-api ^>=0.17, ouroboros-network-framework ^>=0.20, - ouroboros-network-protocols, text, typed-protocols, @@ -289,10 +295,9 @@ library cardano-diffusion monoidal-synchronisation, network ^>=3.2.7, network-mux, - ouroboros-network, + ouroboros-network:{ouroboros-network, protocols}, ouroboros-network-api ^>=0.17, ouroboros-network-framework ^>=0.20, - ouroboros-network-protocols ^>=0.16, random, typed-protocols:{typed-protocols, stateful} ^>=1.1, @@ -303,6 +308,274 @@ library cardano-diffusion if flag(asserts) ghc-options: -fno-ignore-asserts +library protocols + import: ghc-options + visibility: public + hs-source-dirs: protocols/lib + -- At this experiment/prototype stage everything is exposed. + -- This has to be tidied up once the design becomes clear. + exposed-modules: + Ouroboros.Network.Protocol.BlockFetch.Client + Ouroboros.Network.Protocol.BlockFetch.Codec + Ouroboros.Network.Protocol.BlockFetch.Server + Ouroboros.Network.Protocol.BlockFetch.Type + Ouroboros.Network.Protocol.ChainSync.Client + Ouroboros.Network.Protocol.ChainSync.ClientPipelined + Ouroboros.Network.Protocol.ChainSync.Codec + Ouroboros.Network.Protocol.ChainSync.PipelineDecision + Ouroboros.Network.Protocol.ChainSync.Server + Ouroboros.Network.Protocol.ChainSync.Type + Ouroboros.Network.Protocol.Codec.Utils + Ouroboros.Network.Protocol.KeepAlive.Client + Ouroboros.Network.Protocol.KeepAlive.Codec + Ouroboros.Network.Protocol.KeepAlive.Server + Ouroboros.Network.Protocol.KeepAlive.Type + Ouroboros.Network.Protocol.LocalStateQuery.Client + Ouroboros.Network.Protocol.LocalStateQuery.Codec + Ouroboros.Network.Protocol.LocalStateQuery.Server + Ouroboros.Network.Protocol.LocalStateQuery.Type + Ouroboros.Network.Protocol.LocalTxMonitor.Client + Ouroboros.Network.Protocol.LocalTxMonitor.Codec + Ouroboros.Network.Protocol.LocalTxMonitor.Server + Ouroboros.Network.Protocol.LocalTxMonitor.Type + Ouroboros.Network.Protocol.LocalTxSubmission.Client + Ouroboros.Network.Protocol.LocalTxSubmission.Codec + Ouroboros.Network.Protocol.LocalTxSubmission.Server + Ouroboros.Network.Protocol.LocalTxSubmission.Type + Ouroboros.Network.Protocol.PeerSharing.Client + Ouroboros.Network.Protocol.PeerSharing.Codec + Ouroboros.Network.Protocol.PeerSharing.Server + Ouroboros.Network.Protocol.PeerSharing.Type + Ouroboros.Network.Protocol.TxSubmission2.Client + Ouroboros.Network.Protocol.TxSubmission2.Codec + Ouroboros.Network.Protocol.TxSubmission2.Server + Ouroboros.Network.Protocol.TxSubmission2.Type + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + other-extensions: + BangPatterns + DataKinds + EmptyCase + ExistentialQuantification + FlexibleContexts + FlexibleInstances + FunctionalDependencies + GADTSyntax + GADTs + GeneralizedNewtypeDeriving + MultiParamTypeClasses + NamedFieldPuns + OverloadedStrings + PolyKinds + RankNTypes + RecordWildCards + ScopedTypeVariables + TemplateHaskell + TupleSections + TypeApplications + TypeFamilies + TypeInType + + build-depends: + base >=4.14 && <4.22, + bytestring >=0.10 && <0.13, + cborg >=0.2.1 && <0.3, + constraints, + containers, + deepseq, + io-classes:{io-classes, si-timers} ^>=1.8.0.1, + nothunks, + ouroboros-network-api ^>=0.17, + quiet, + random, + serialise, + singletons, + text, + typed-protocols:{typed-protocols, cborg, stateful, stateful-cborg} ^>=1.1, + + if flag(asserts) + ghc-options: -fno-ignore-asserts + +library protocols-tests-lib + import: ghc-options + visibility: public + hs-source-dirs: protocols/tests-lib + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + exposed-modules: + Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL + Ouroboros.Network.Protocol.BlockFetch.Direct + Ouroboros.Network.Protocol.BlockFetch.Examples + Ouroboros.Network.Protocol.BlockFetch.Test + Ouroboros.Network.Protocol.ChainSync.Codec.CDDL + Ouroboros.Network.Protocol.ChainSync.Direct + Ouroboros.Network.Protocol.ChainSync.DirectPipelined + Ouroboros.Network.Protocol.ChainSync.Examples + Ouroboros.Network.Protocol.ChainSync.ExamplesPipelined + Ouroboros.Network.Protocol.ChainSync.Test + Ouroboros.Network.Protocol.Handshake.Direct + Ouroboros.Network.Protocol.Handshake.Test + Ouroboros.Network.Protocol.KeepAlive.Direct + Ouroboros.Network.Protocol.KeepAlive.Examples + Ouroboros.Network.Protocol.KeepAlive.Test + Ouroboros.Network.Protocol.LocalStateQuery.Codec.CDDL + Ouroboros.Network.Protocol.LocalStateQuery.Direct + Ouroboros.Network.Protocol.LocalStateQuery.Examples + Ouroboros.Network.Protocol.LocalStateQuery.Test + Ouroboros.Network.Protocol.LocalTxMonitor.Codec.CDDL + Ouroboros.Network.Protocol.LocalTxMonitor.Direct + Ouroboros.Network.Protocol.LocalTxMonitor.Examples + Ouroboros.Network.Protocol.LocalTxMonitor.Test + Ouroboros.Network.Protocol.LocalTxSubmission.Codec.CDDL + Ouroboros.Network.Protocol.LocalTxSubmission.Direct + Ouroboros.Network.Protocol.LocalTxSubmission.Examples + Ouroboros.Network.Protocol.LocalTxSubmission.Test + Ouroboros.Network.Protocol.PeerSharing.Codec.CDDL + Ouroboros.Network.Protocol.PeerSharing.Direct + Ouroboros.Network.Protocol.PeerSharing.Examples + Ouroboros.Network.Protocol.PeerSharing.Test + Ouroboros.Network.Protocol.TxSubmission2.Codec.CDDL + Ouroboros.Network.Protocol.TxSubmission2.Direct + Ouroboros.Network.Protocol.TxSubmission2.Examples + Ouroboros.Network.Protocol.TxSubmission2.Test + Test.ChainGenerators + Test.ChainProducerState + Test.Data.CDDL + Test.Data.PipeliningDepth + Test.Ouroboros.Network.Protocol.Utils + + build-depends: + QuickCheck, + base >=4.14 && <4.22, + bytestring, + cardano-slotting:testlib ^>=0.2.0, + cardano-strict-containers, + cborg, + containers, + contra-tracer, + deepseq, + io-classes:{io-classes, si-timers, strict-stm}, + io-sim, + network, + network-mux, + ouroboros-network:protocols, + ouroboros-network-api, + ouroboros-network-framework, + ouroboros-network-mock, + ouroboros-network-testing, + pipes, + quickcheck-instances, + serialise, + tasty, + tasty-quickcheck, + text, + typed-protocols:{typed-protocols, codec-properties, stateful}, + +test-suite protocols-tests + import: ghc-options + type: exitcode-stdio-1.0 + hs-source-dirs: protocols/tests + main-is: Main.hs + -- TODO: these two tests should be moved to `ouroboros-network-mock` + other-modules: + Test.AnchoredFragment + Test.Chain + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + build-depends: + QuickCheck ^>=2.16, + base >=4.14 && <4.22, + ouroboros-network:protocols-tests-lib, + ouroboros-network-api, + ouroboros-network-mock, + ouroboros-network-testing ^>=0.8, + tasty, + tasty-quickcheck, + + ghc-options: + -threaded + -Wall + -Wunused-packages + -rtsopts + +test-suite protocols-cddl + import: ghc-options + type: exitcode-stdio-1.0 + hs-source-dirs: protocols/cddl + main-is: Main.hs + + if flag(cddl) + buildable: True + else + buildable: False + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + build-depends: + QuickCheck, + base >=4.14 && <4.22, + bytestring, + cborg, + containers, + directory, + filepath, + mtl, + network, + ouroboros-network:{protocols, protocols-tests-lib}, + ouroboros-network-api, + ouroboros-network-framework, + ouroboros-network-mock, + process-extras, + quickcheck-instances, + serialise, + tasty, + tasty-hunit, + tasty-quickcheck, + temporary, + text, + typed-protocols:{typed-protocols, stateful}, + + ghc-options: + -threaded + -Wall + -rtsopts + -with-rtsopts=-M400m + +test-suite protocols-bench + type: exitcode-stdio-1.0 + default-extensions: ImportQualifiedPost + hs-source-dirs: protocols/bench + main-is: Main.hs + default-language: Haskell2010 + build-depends: + base >=4.14 && <4.22, + bytestring, + cborg, + containers, + deepseq, + network, + ouroboros-network:{protocols, protocols-tests-lib}, + ouroboros-network-api, + ouroboros-network-framework, + tasty-bench, + typed-protocols:{typed-protocols, stateful}, + + ghc-options: + -Wall + -Wno-unticked-promoted-constructors + -Wcompat + -Wunused-packages + -rtsopts + -with-rtsopts=-A32m + -with-rtsopts=-T + + -- Important for comparing benchmarks results against a baseline run. + -- Read: https://hackage.haskell.org/package/tasty-bench for details + if impl(ghc >=8.6) + ghc-options: -fproc-alignment=64 + -- Simulation Test Library library testlib import: ghc-options-tests @@ -333,12 +606,11 @@ library testlib network-mux, nothunks, ouroboros-network:{ouroboros-network, cardano-diffusion, orphan-instances}, + ouroboros-network:{protocols, protocols-tests-lib}, ouroboros-network-api, ouroboros-network-framework, ouroboros-network-framework:testlib, ouroboros-network-mock, - ouroboros-network-protocols, - ouroboros-network-protocols:testlib, ouroboros-network-testing ^>=0.8.3, pipes, pretty-simple, @@ -404,8 +676,7 @@ test-suite sim-tests main-is: Main.hs build-depends: base >=4.14 && <4.22, - ouroboros-network:testlib, - ouroboros-network-protocols:testlib, + ouroboros-network:{protocols-tests-lib, testlib}, tasty, with-utf8, @@ -442,11 +713,10 @@ test-suite io-tests network, network-mux, ouroboros-network:cardano-diffusion, + ouroboros-network:{protocols, protocols-tests-lib}, ouroboros-network-api, ouroboros-network-framework, ouroboros-network-mock, - ouroboros-network-protocols, - ouroboros-network-protocols:testlib, ouroboros-network-testing ^>=0.8.1, serialise, tasty, @@ -483,10 +753,10 @@ executable demo-chain-sync network-mux, optparse-applicative, ouroboros-network:{ouroboros-network, cardano-diffusion}, + ouroboros-network:protocols, ouroboros-network-api, ouroboros-network-framework, ouroboros-network-mock, - ouroboros-network-protocols, random, serialise, typed-protocols, diff --git a/ouroboros-network-protocols/bench-cddl/Main.hs b/ouroboros-network/protocols/bench/Main.hs similarity index 100% rename from ouroboros-network-protocols/bench-cddl/Main.hs rename to ouroboros-network/protocols/bench/Main.hs diff --git a/ouroboros-network-protocols/cddl/Main.hs b/ouroboros-network/protocols/cddl/Main.hs similarity index 98% rename from ouroboros-network-protocols/cddl/Main.hs rename to ouroboros-network/protocols/cddl/Main.hs index a528d26586d..e243f09517e 100644 --- a/ouroboros-network-protocols/cddl/Main.hs +++ b/ouroboros-network/protocols/cddl/Main.hs @@ -257,9 +257,9 @@ cddlc path = do readCDDLSpecs :: IO CDDLSpecs readCDDLSpecs = do - dir <- bool ( "cddl" "specs") -- False - ("ouroboros-network-protocols" "cddl" "specs") -- True - <$> doesDirectoryExist "ouroboros-network-protocols" + dir <- bool ( "protocols" "cddl" "specs") -- False + ("ouroboros-network" "protocols" "cddl" "specs") -- True + <$> doesDirectoryExist "ouroboros-network" setEnv "CDDL_INCLUDE_PATH" (dir <> ":") handshakeNodeToClient <- cddlc (dir "handshake-node-to-client.cddl") @@ -300,9 +300,7 @@ readCDDLSpecs = do -- validateEncoder :: forall ps. - ( forall (st :: ps) sing. sing ~ StateToken st => Show sing - ) - => CDDLSpec ps + CDDLSpec ps -> Codec ps CBOR.DeserialiseFailure IO BL.ByteString -> AnyMessage ps -> Property @@ -359,9 +357,7 @@ validateCBORTermEncoder spec validateEncoderSt :: forall ps f. - ( forall (st :: ps) sing. sing ~ StateToken st => Show sing - ) - => CDDLSpec ps + CDDLSpec ps -> Stateful.Codec ps CBOR.DeserialiseFailure f IO BL.ByteString -> Stateful.AnyMessage ps f -> Property @@ -1004,7 +1000,7 @@ handshakeFix term = , TMap (sortOn (\(k, _) -> case k of TInt i -> (fromIntegral i :: Integer) - TInteger i -> (fromIntegral i :: Integer) + TInteger i -> i _ -> error "orderHandshakeDict: unexpected key") l ) diff --git a/ouroboros-network-protocols/cddl/specs/block-fetch.cddl b/ouroboros-network/protocols/cddl/specs/block-fetch.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/block-fetch.cddl rename to ouroboros-network/protocols/cddl/specs/block-fetch.cddl diff --git a/ouroboros-network-protocols/cddl/specs/chain-sync.cddl b/ouroboros-network/protocols/cddl/specs/chain-sync.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/chain-sync.cddl rename to ouroboros-network/protocols/cddl/specs/chain-sync.cddl diff --git a/ouroboros-network-protocols/cddl/specs/handshake-node-to-client.cddl b/ouroboros-network/protocols/cddl/specs/handshake-node-to-client.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/handshake-node-to-client.cddl rename to ouroboros-network/protocols/cddl/specs/handshake-node-to-client.cddl diff --git a/ouroboros-network-protocols/cddl/specs/handshake-node-to-node-v14.cddl b/ouroboros-network/protocols/cddl/specs/handshake-node-to-node-v14.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/handshake-node-to-node-v14.cddl rename to ouroboros-network/protocols/cddl/specs/handshake-node-to-node-v14.cddl diff --git a/ouroboros-network-protocols/cddl/specs/keep-alive.cddl b/ouroboros-network/protocols/cddl/specs/keep-alive.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/keep-alive.cddl rename to ouroboros-network/protocols/cddl/specs/keep-alive.cddl diff --git a/ouroboros-network-protocols/cddl/specs/local-state-query.cddl b/ouroboros-network/protocols/cddl/specs/local-state-query.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/local-state-query.cddl rename to ouroboros-network/protocols/cddl/specs/local-state-query.cddl diff --git a/ouroboros-network-protocols/cddl/specs/local-tx-monitor.cddl b/ouroboros-network/protocols/cddl/specs/local-tx-monitor.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/local-tx-monitor.cddl rename to ouroboros-network/protocols/cddl/specs/local-tx-monitor.cddl diff --git a/ouroboros-network-protocols/cddl/specs/local-tx-submission.cddl b/ouroboros-network/protocols/cddl/specs/local-tx-submission.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/local-tx-submission.cddl rename to ouroboros-network/protocols/cddl/specs/local-tx-submission.cddl diff --git a/ouroboros-network-protocols/cddl/specs/network.base.cddl b/ouroboros-network/protocols/cddl/specs/network.base.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/network.base.cddl rename to ouroboros-network/protocols/cddl/specs/network.base.cddl diff --git a/ouroboros-network-protocols/cddl/specs/node-to-node-version-data-v14.cddl b/ouroboros-network/protocols/cddl/specs/node-to-node-version-data-v14.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/node-to-node-version-data-v14.cddl rename to ouroboros-network/protocols/cddl/specs/node-to-node-version-data-v14.cddl diff --git a/ouroboros-network-protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl b/ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl rename to ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl diff --git a/ouroboros-network-protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl b/ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl rename to ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl diff --git a/ouroboros-network-protocols/cddl/specs/obsolete/handshake-node-to-node.cddl b/ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/obsolete/handshake-node-to-node.cddl rename to ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node.cddl diff --git a/ouroboros-network-protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl b/ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl rename to ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl diff --git a/ouroboros-network-protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl b/ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl rename to ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl diff --git a/ouroboros-network-protocols/cddl/specs/obsolete/node-to-node-version-data.cddl b/ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/obsolete/node-to-node-version-data.cddl rename to ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data.cddl diff --git a/ouroboros-network-protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl b/ouroboros-network/protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl rename to ouroboros-network/protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl diff --git a/ouroboros-network-protocols/cddl/specs/obsolete/peer-sharing-v13.cddl b/ouroboros-network/protocols/cddl/specs/obsolete/peer-sharing-v13.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/obsolete/peer-sharing-v13.cddl rename to ouroboros-network/protocols/cddl/specs/obsolete/peer-sharing-v13.cddl diff --git a/ouroboros-network-protocols/cddl/specs/peer-sharing-v14.cddl b/ouroboros-network/protocols/cddl/specs/peer-sharing-v14.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/peer-sharing-v14.cddl rename to ouroboros-network/protocols/cddl/specs/peer-sharing-v14.cddl diff --git a/ouroboros-network-protocols/cddl/specs/tx-submission2.cddl b/ouroboros-network/protocols/cddl/specs/tx-submission2.cddl similarity index 100% rename from ouroboros-network-protocols/cddl/specs/tx-submission2.cddl rename to ouroboros-network/protocols/cddl/specs/tx-submission2.cddl diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Client.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Client.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Client.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Client.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Codec.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Codec.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Codec.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Server.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Server.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Server.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Server.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Type.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Type.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Type.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Client.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Client.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Client.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Client.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/ClientPipelined.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/ClientPipelined.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/ClientPipelined.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/ClientPipelined.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Codec.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Codec.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Codec.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/PipelineDecision.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/PipelineDecision.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/PipelineDecision.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/PipelineDecision.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Server.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Server.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Server.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Server.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Type.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Type.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Type.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/Codec/Utils.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/Codec/Utils.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/Codec/Utils.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/Codec/Utils.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Client.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Client.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Client.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Client.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Codec.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Codec.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Codec.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Server.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Server.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Server.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Server.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Type.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Type.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Type.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Client.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Client.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Client.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Client.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Server.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Server.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Server.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Server.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Client.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Server.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Server.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Server.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Server.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Client.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Client.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Client.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Client.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Codec.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Codec.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Codec.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Server.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Server.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Server.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Server.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Type.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Type.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Type.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Client.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Client.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Client.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Client.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Codec.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Codec.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Codec.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Server.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Server.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Server.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Server.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Type.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Type.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Type.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Client.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Client.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Client.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Client.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Codec.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Codec.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Codec.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Server.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Server.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Server.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Server.hs diff --git a/ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Type.hs similarity index 100% rename from ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Type.hs rename to ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Type.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/BlockFetch/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Codec/CDDL.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/BlockFetch/Codec/CDDL.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Codec/CDDL.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/BlockFetch/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/BlockFetch/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/BlockFetch/Examples.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Examples.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/BlockFetch/Examples.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Examples.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/BlockFetch/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Test.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/BlockFetch/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Test.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Codec/CDDL.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Codec/CDDL.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Codec/CDDL.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/DirectPipelined.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/DirectPipelined.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/DirectPipelined.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/DirectPipelined.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Examples.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Examples.hs similarity index 99% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Examples.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Examples.hs index 55978b457e4..014e76dc27d 100644 --- a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Examples.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Examples.hs @@ -74,7 +74,6 @@ controlledClient controlMessageSTM = go -- chainSyncClientExample :: forall header block tip m a. ( HasHeader header - , HasHeader block , HeaderHash header ~ HeaderHash block , MonadSTM m ) @@ -167,7 +166,6 @@ recentOffsets = [0,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584] chainSyncServerExample :: forall blk header m a. ( HasHeader blk , MonadSTM m - , HeaderHash header ~ HeaderHash blk ) => a -> StrictTVar m (ChainProducerState blk) diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/ExamplesPipelined.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/ExamplesPipelined.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/ExamplesPipelined.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/ExamplesPipelined.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Test.hs similarity index 99% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Test.hs index 2ebb2d78583..8471a58ce09 100644 --- a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/ChainSync/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Test.hs @@ -18,7 +18,6 @@ import Data.ByteString.Lazy (ByteString) import Control.Concurrent.Class.MonadSTM.Strict import Control.Monad.Class.MonadAsync import Control.Monad.Class.MonadFork -import Control.Monad.Class.MonadSay import Control.Monad.Class.MonadST import Control.Monad.Class.MonadThrow import Control.Tracer (nullTracer) @@ -134,9 +133,7 @@ testClient doneVar tip = -- chainSyncForkExperiment :: forall m. - ( MonadST m - , MonadSTM m - ) + MonadSTM m => (forall a b. ChainSyncServer Block (Point Block) (Tip Block) m a -> ChainSyncClient Block (Point Block) (Tip Block) m b @@ -194,9 +191,7 @@ propChainSyncConnectIO cps = -- chainSyncPipelinedForkExperiment :: forall m. - ( MonadST m - , MonadSTM m - ) + MonadSTM m => (forall a b. ChainSyncServer Block (Point Block) (Tip Block) m a -> ChainSyncClientPipelined Block (Point Block) (Tip Block) m b -> m ()) @@ -673,11 +668,9 @@ propChainSyncPipe cps = chainSyncDemoPipelined :: forall m. ( MonadST m - , MonadSTM m , MonadFork m , MonadAsync m , MonadThrow m - , MonadSay m ) => Channel m ByteString -> Channel m ByteString diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/Handshake/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/Handshake/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/Handshake/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs similarity index 99% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/Handshake/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs index a5dbd121f0c..525f6e85d32 100644 --- a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/Handshake/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs @@ -30,7 +30,6 @@ import Codec.CBOR.Term qualified as CBOR import Control.Applicative (Alternative) import Control.Concurrent.Class.MonadSTM.Strict import Control.Monad.Class.MonadAsync -import Control.Monad.Class.MonadFork import Control.Monad.Class.MonadST (MonadST) import Control.Monad.Class.MonadThrow (MonadCatch, MonadMask, MonadThrow, bracket) @@ -191,9 +190,7 @@ versionNumberCodec = CodecCBORTerm { encodeTerm, decodeTerm } decodeTerm _ = Left ("unknown tag", Nothing) -versionNumberHandshakeCodec :: ( MonadST m - , MonadThrow m - ) +versionNumberHandshakeCodec :: MonadST m => Codec (Handshake VersionNumber CBOR.Term) CBOR.DeserialiseFailure m ByteString versionNumberHandshakeCodec = codecHandshake versionNumberCodec @@ -548,8 +545,6 @@ prop_pipe_IO (ArbitraryVersions clientVersions serverVersions) = -- prop_channel_asymmetric :: ( MonadAsync m - , MonadCatch m - , MonadLabelledSTM m , MonadMask m , MonadST m ) @@ -932,7 +927,6 @@ prop_query_version_NodeToClient_SimNet -- prop_query_version :: ( MonadAsync m , MonadCatch m - , MonadST m , Eq vData , Acceptable vData , Queryable vData @@ -980,9 +974,9 @@ prop_query_version createChannels codec versionDataCodec clientVersions serverVe -- | Run a query for the server's supported version. -- -prop_peerSharing_symmetric :: ( MonadAsync m +prop_peerSharing_symmetric :: + ( MonadAsync m , MonadCatch m - , MonadST m ) => m (Channel m ByteString, Channel m ByteString) -> Codec (Handshake NodeToNodeVersion CBOR.Term) @@ -1053,8 +1047,6 @@ prop_acceptOrRefuse_symmetric , Show vData , Ord vNumber , Show vNumber - , Eq r - , Show r ) => Versions vNumber vData r -> Versions vNumber vData r @@ -1126,7 +1118,6 @@ prop_acceptOrRefuse_symmetric_NodeToClient (ArbitraryNodeToClientVersions a) prop_channel_simultaneous_open :: ( MonadAsync m , MonadCatch m - , MonadST m , Acceptable vData , Ord vNumber ) @@ -1271,13 +1262,9 @@ prop_channel_simultaneous_open_sim :: forall vNumber vData m. ( Alternative (STM m) , MonadAsync m - , MonadCatch m , MonadDelay m - , MonadFork m , MonadLabelledSTM m , MonadMask m - , MonadMonotonicTime m - , MonadST m , MonadThrow (STM m) , MonadTime m , MonadTimer m diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/KeepAlive/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/KeepAlive/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/KeepAlive/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/KeepAlive/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/KeepAlive/Examples.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/KeepAlive/Examples.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/KeepAlive/Examples.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/KeepAlive/Examples.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/KeepAlive/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/KeepAlive/Test.hs similarity index 98% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/KeepAlive/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/KeepAlive/Test.hs index 433cc5694ce..58c195e1da2 100644 --- a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/KeepAlive/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/KeepAlive/Test.hs @@ -10,7 +10,6 @@ module Ouroboros.Network.Protocol.KeepAlive.Test where import Control.Monad.Class.MonadAsync import Control.Monad.Class.MonadST -import Control.Monad.Class.MonadSTM import Control.Monad.Class.MonadThrow import Control.Monad.IOSim (runSimOrThrow) import Control.Monad.ST (runST) @@ -96,7 +95,6 @@ prop_connect f (NonNegative n) = -- prop_channel :: ( MonadST m - , MonadSTM m , MonadAsync m , MonadCatch m ) diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec/CDDL.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Codec/CDDL.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec/CDDL.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Examples.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Examples.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Examples.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Examples.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs similarity index 99% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs index 727aadebf8f..108a3c455fb 100644 --- a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs @@ -24,7 +24,7 @@ import Data.Map qualified as Map import Control.Monad.Class.MonadAsync (MonadAsync) import Control.Monad.Class.MonadST (MonadST) -import Control.Monad.Class.MonadThrow (MonadCatch, MonadMask) +import Control.Monad.Class.MonadThrow (MonadMask) import Control.Monad.IOSim import Control.Monad.ST (runST) import Control.Tracer (nullTracer) @@ -204,7 +204,6 @@ prop_connect input = -- | Run a local state query client and server using connected channels. -- prop_channel :: ( MonadAsync m - , MonadCatch m , MonadMask m , MonadST m ) diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Examples.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Examples.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Examples.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Examples.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxSubmission/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxSubmission/Codec/CDDL.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxSubmission/Codec/CDDL.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxSubmission/Codec/CDDL.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxSubmission/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxSubmission/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxSubmission/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxSubmission/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxSubmission/Examples.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxSubmission/Examples.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxSubmission/Examples.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxSubmission/Examples.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxSubmission/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxSubmission/Test.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/LocalTxSubmission/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxSubmission/Test.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/PeerSharing/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/PeerSharing/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/PeerSharing/Examples.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Examples.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/PeerSharing/Examples.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Examples.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/PeerSharing/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Test.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/PeerSharing/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Test.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/TxSubmission2/Codec/CDDL.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Codec/CDDL.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/TxSubmission2/Codec/CDDL.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Direct.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/TxSubmission2/Direct.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Direct.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/TxSubmission2/Direct.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Examples.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/TxSubmission2/Examples.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Examples.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/TxSubmission2/Examples.hs diff --git a/ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/TxSubmission2/Test.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Test.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/TxSubmission2/Test.hs diff --git a/ouroboros-network-protocols/testlib/Test/ChainGenerators.hs b/ouroboros-network/protocols/tests-lib/Test/ChainGenerators.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Test/ChainGenerators.hs rename to ouroboros-network/protocols/tests-lib/Test/ChainGenerators.hs diff --git a/ouroboros-network-protocols/testlib/Test/ChainProducerState.hs b/ouroboros-network/protocols/tests-lib/Test/ChainProducerState.hs similarity index 99% rename from ouroboros-network-protocols/testlib/Test/ChainProducerState.hs rename to ouroboros-network/protocols/tests-lib/Test/ChainProducerState.hs index 8b05dbcf117..814d4859bcd 100644 --- a/ouroboros-network-protocols/testlib/Test/ChainProducerState.hs +++ b/ouroboros-network/protocols/tests-lib/Test/ChainProducerState.hs @@ -193,7 +193,7 @@ genFollowerState n c = do followerPoint <- frequency [ (2, return (headPoint c)) , (2, return (mkRollbackPoint c n)) - , (8, mkRollbackPoint c <$> choose (1, fromIntegral n - 1)) + , (8, mkRollbackPoint c <$> choose (1, n - 1)) ] followerNext <- oneof [ return FollowerForwardFrom diff --git a/ouroboros-network-protocols/testlib/Test/Data/CDDL.hs b/ouroboros-network/protocols/tests-lib/Test/Data/CDDL.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Test/Data/CDDL.hs rename to ouroboros-network/protocols/tests-lib/Test/Data/CDDL.hs diff --git a/ouroboros-network-protocols/testlib/Test/Data/PipeliningDepth.hs b/ouroboros-network/protocols/tests-lib/Test/Data/PipeliningDepth.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Test/Data/PipeliningDepth.hs rename to ouroboros-network/protocols/tests-lib/Test/Data/PipeliningDepth.hs diff --git a/ouroboros-network-protocols/testlib/Test/Ouroboros/Network/Protocol/Utils.hs b/ouroboros-network/protocols/tests-lib/Test/Ouroboros/Network/Protocol/Utils.hs similarity index 100% rename from ouroboros-network-protocols/testlib/Test/Ouroboros/Network/Protocol/Utils.hs rename to ouroboros-network/protocols/tests-lib/Test/Ouroboros/Network/Protocol/Utils.hs diff --git a/ouroboros-network-protocols/test/Main.hs b/ouroboros-network/protocols/tests/Main.hs similarity index 100% rename from ouroboros-network-protocols/test/Main.hs rename to ouroboros-network/protocols/tests/Main.hs diff --git a/ouroboros-network-protocols/test/Test/AnchoredFragment.hs b/ouroboros-network/protocols/tests/Test/AnchoredFragment.hs similarity index 100% rename from ouroboros-network-protocols/test/Test/AnchoredFragment.hs rename to ouroboros-network/protocols/tests/Test/AnchoredFragment.hs diff --git a/ouroboros-network-protocols/test/Test/Chain.hs b/ouroboros-network/protocols/tests/Test/Chain.hs similarity index 100% rename from ouroboros-network-protocols/test/Test/Chain.hs rename to ouroboros-network/protocols/tests/Test/Chain.hs From 95a668214c423009a710c61782344773591d66c0 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Mon, 15 Sep 2025 17:43:44 +0200 Subject: [PATCH 03/24] Moved ouroboros-network-framework to ouroboros-newtork:framework * `ouroboros-network-framework` -> `ouroboros-network:framework` in `framework/lib` * `ouroboros-network-framework:testlib` -> `ouroboros-network:framework-tests-lib` in `framework/tests-lib` * `ouroboros-network-framework:sim-tests` -> `ouroboros-network:framework-sim-tests` in `framework/sim-tests` * `ouroboros-network-framework:io-tests` -> `ouroboros-network:framework-io-tests` in `framework/io-tests` * `ouroboros-network-framework:demo-connection-manager` -> `ouroboros-network:demo-connection-manager` in `demo` * `ouroboros-network-framework:demo-ping-pong` -> `ouroboros-network:demo-ping-pong` in `demo` --- cabal.project | 1 - cardano-client/cardano-client.cabal | 3 +- dmq-node/dmq-node.cabal | 5 +- ouroboros-network-framework/CHANGELOG.md | 434 ------------------ ouroboros-network-framework/LICENSE | 177 ------- ouroboros-network-framework/NOTICE | 14 - ouroboros-network-framework/Setup.hs | 2 - .../changelog.d/scriv.ini | 15 - .../ouroboros-network-framework.cabal | 310 ------------- ouroboros-network-framework/test/Main.hs | 30 -- .../demo/connection-manager.hs | 0 .../demo/ping-pong.hs | 0 .../framework}/io-tests/Main.hs | 0 .../io-tests/Test/Ouroboros/Network/Driver.hs | 0 .../Test/Ouroboros/Network/RawBearer.hs | 0 .../Test/Ouroboros/Network/Server/IO.hs | 0 .../io-tests/Test/Ouroboros/Network/Socket.hs | 0 .../Test/Ouroboros/Network/Subscription.hs | 0 .../framework/lib}/Data/Cache.hs | 0 .../framework/lib}/Data/Wedge.hs | 0 .../framework/lib}/NoThunks/Class/Orphans.hs | 0 .../lib}/Ouroboros/Network/Channel.hs | 0 .../Ouroboros/Network/ConnectionHandler.hs | 0 .../lib}/Ouroboros/Network/ConnectionId.hs | 0 .../Network/ConnectionManager/ConnMap.hs | 0 .../Network/ConnectionManager/Core.hs | 0 .../Network/ConnectionManager/State.hs | 0 .../Network/ConnectionManager/Types.hs | 0 .../lib}/Ouroboros/Network/Context.hs | 0 .../lib}/Ouroboros/Network/Driver.hs | 0 .../lib}/Ouroboros/Network/Driver/Limits.hs | 0 .../lib}/Ouroboros/Network/Driver/Simple.hs | 0 .../lib}/Ouroboros/Network/Driver/Stateful.hs | 0 .../lib}/Ouroboros/Network/IOManager.hs | 0 .../lib}/Ouroboros/Network/InboundGovernor.hs | 0 .../InboundGovernor/InformationChannel.hs | 0 .../Network/InboundGovernor/State.hs | 0 .../framework/lib}/Ouroboros/Network/Mux.hs | 0 .../lib}/Ouroboros/Network/MuxMode.hs | 0 .../Ouroboros/Network/Protocol/Handshake.hs | 0 .../Network/Protocol/Handshake/Client.hs | 0 .../Network/Protocol/Handshake/Codec.hs | 0 .../Network/Protocol/Handshake/Server.hs | 0 .../Network/Protocol/Handshake/Type.hs | 0 .../Network/Protocol/Handshake/Unversioned.hs | 0 .../Network/Protocol/Handshake/Version.hs | 0 .../lib}/Ouroboros/Network/RawBearer.hs | 0 .../lib}/Ouroboros/Network/RethrowPolicy.hs | 0 .../lib}/Ouroboros/Network/Server.hs | 0 .../Network/Server/ConnectionTable.hs | 0 .../Ouroboros/Network/Server/RateLimiting.hs | 0 .../lib}/Ouroboros/Network/Server/Simple.hs | 0 .../lib}/Ouroboros/Network/Snocket.hs | 0 .../lib}/Ouroboros/Network/Socket.hs | 0 .../lib}/Simulation/Network/Snocket.hs | 0 .../framework}/sim-tests/Main.hs | 0 .../Ouroboros/Network/ConnectionManager.hs | 0 .../Test/Ouroboros/Network/RateLimiting.hs | 0 .../Test/Ouroboros/Network/RawBearer.hs | 0 .../Test/Ouroboros/Network/Server/Sim.hs | 0 .../Test/Ouroboros/Network/Subscription.hs | 0 .../Test/Simulation/Network/Snocket.hs | 0 .../Network/ConnectionManager/Experiments.hs | 0 .../Network/ConnectionManager/Timeouts.hs | 0 .../Network/ConnectionManager/Utils.hs | 0 .../Network/InboundGovernor/Utils.hs | 0 .../Test/Ouroboros/Network/Orphans.hs | 0 .../Test/Ouroboros/Network/RawBearer/Utils.hs | 0 ouroboros-network/ouroboros-network.cabal | 289 +++++++++++- 69 files changed, 273 insertions(+), 1007 deletions(-) delete mode 100644 ouroboros-network-framework/CHANGELOG.md delete mode 100644 ouroboros-network-framework/LICENSE delete mode 100644 ouroboros-network-framework/NOTICE delete mode 100644 ouroboros-network-framework/Setup.hs delete mode 100644 ouroboros-network-framework/changelog.d/scriv.ini delete mode 100644 ouroboros-network-framework/ouroboros-network-framework.cabal delete mode 100644 ouroboros-network-framework/test/Main.hs rename {ouroboros-network-framework => ouroboros-network}/demo/connection-manager.hs (100%) rename {ouroboros-network-framework => ouroboros-network}/demo/ping-pong.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/io-tests/Main.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/io-tests/Test/Ouroboros/Network/Driver.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/io-tests/Test/Ouroboros/Network/RawBearer.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/io-tests/Test/Ouroboros/Network/Server/IO.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/io-tests/Test/Ouroboros/Network/Socket.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/io-tests/Test/Ouroboros/Network/Subscription.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Data/Cache.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Data/Wedge.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/NoThunks/Class/Orphans.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Channel.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/ConnectionHandler.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/ConnectionId.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/ConnectionManager/ConnMap.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/ConnectionManager/Core.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/ConnectionManager/State.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/ConnectionManager/Types.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Context.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Driver.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Driver/Limits.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Driver/Simple.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Driver/Stateful.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/IOManager.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/InboundGovernor.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/InboundGovernor/InformationChannel.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/InboundGovernor/State.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Mux.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/MuxMode.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Protocol/Handshake.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Protocol/Handshake/Client.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Protocol/Handshake/Codec.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Protocol/Handshake/Server.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Protocol/Handshake/Type.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Protocol/Handshake/Unversioned.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Protocol/Handshake/Version.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/RawBearer.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/RethrowPolicy.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Server.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Server/ConnectionTable.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Server/RateLimiting.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Server/Simple.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Snocket.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Ouroboros/Network/Socket.hs (100%) rename {ouroboros-network-framework/src => ouroboros-network/framework/lib}/Simulation/Network/Snocket.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/sim-tests/Main.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/sim-tests/Test/Ouroboros/Network/RateLimiting.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/sim-tests/Test/Ouroboros/Network/RawBearer.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/sim-tests/Test/Ouroboros/Network/Server/Sim.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/sim-tests/Test/Ouroboros/Network/Subscription.hs (100%) rename {ouroboros-network-framework => ouroboros-network/framework}/sim-tests/Test/Simulation/Network/Snocket.hs (100%) rename {ouroboros-network-framework/testlib => ouroboros-network/framework/tests-lib}/Test/Ouroboros/Network/ConnectionManager/Experiments.hs (100%) rename {ouroboros-network-framework/testlib => ouroboros-network/framework/tests-lib}/Test/Ouroboros/Network/ConnectionManager/Timeouts.hs (100%) rename {ouroboros-network-framework/testlib => ouroboros-network/framework/tests-lib}/Test/Ouroboros/Network/ConnectionManager/Utils.hs (100%) rename {ouroboros-network-framework/testlib => ouroboros-network/framework/tests-lib}/Test/Ouroboros/Network/InboundGovernor/Utils.hs (100%) rename {ouroboros-network-framework/testlib => ouroboros-network/framework/tests-lib}/Test/Ouroboros/Network/Orphans.hs (100%) rename {ouroboros-network-framework/testlib => ouroboros-network/framework/tests-lib}/Test/Ouroboros/Network/RawBearer/Utils.hs (100%) diff --git a/cabal.project b/cabal.project index d509ab50665..4207373b16c 100644 --- a/cabal.project +++ b/cabal.project @@ -25,7 +25,6 @@ packages: ./cardano-ping ./network-mux ./ouroboros-network ./ouroboros-network-api - ./ouroboros-network-framework ./ouroboros-network-mock ./ouroboros-network-testing ./ntp-client diff --git a/cardano-client/cardano-client.cabal b/cardano-client/cardano-client.cabal index c408abc0749..9296552b6c8 100644 --- a/cardano-client/cardano-client.cabal +++ b/cardano-client/cardano-client.cabal @@ -28,9 +28,8 @@ library contra-tracer >=0.1 && <0.3, io-classes:si-timers ^>=1.8.0.1, network-mux ^>=0.9, - ouroboros-network:cardano-diffusion ^>=0.23, + ouroboros-network:{cardano-diffusion, framework} ^>=0.23, ouroboros-network-api ^>=0.17, - ouroboros-network-framework ^>=0.20, ghc-options: -Wall diff --git a/dmq-node/dmq-node.cabal b/dmq-node/dmq-node.cabal index bd5ede309f2..16aea2e0227 100644 --- a/dmq-node/dmq-node.cabal +++ b/dmq-node/dmq-node.cabal @@ -103,9 +103,8 @@ library network ^>=3.2.7, network-mux ^>=0.9.1, optparse-applicative ^>=0.18, - ouroboros-network:{ouroboros-network, orphan-instances, protocols} ^>=0.23, + ouroboros-network:{ouroboros-network, framework, orphan-instances, protocols} ^>=0.23, ouroboros-network-api ^>=0.17, - ouroboros-network-framework ^>=0.20, random ^>=1.2, singletons, text >=1.2.4 && <2.2, @@ -173,9 +172,9 @@ test-suite dmq-test io-classes, io-sim, kes-agent-crypto, + ouroboros-network:{framework, protocols, protocols-tests-lib}, ouroboros-network:{protocols, protocols-tests-lib}, ouroboros-network-api, - ouroboros-network-framework, ouroboros-network-testing, quickcheck-instances, serialise, diff --git a/ouroboros-network-framework/CHANGELOG.md b/ouroboros-network-framework/CHANGELOG.md deleted file mode 100644 index 62cd9f4e8ef..00000000000 --- a/ouroboros-network-framework/CHANGELOG.md +++ /dev/null @@ -1,434 +0,0 @@ -# Revision history for ouroboros-network-framework - - - - -## 0.20.0.0 -- 10.09.2025 - -### Breaking changes - -* `HandleError` renamed as `HandlerError`, also `HandlerErrorType` and `classifyHandlerError`. - -### Non-breaking changes - -* propagate diconnection reason out of connection manager when including an - inbound connection or acquiring an outbound connection. -* added `runAnnotatedConnectedPeers`. - -## 0.19.0.0 -- 28.06.2025 - -### Breaking changes - -* IG performance related improvements changing to interfaces of - * IG `with` and `Arguments` - * CM `with` and `Arguments` - * Server `with` and `Arguments` - * Deleted `InboundGovernor.Event` module and moved to InboundGovernor: - * `NewConnectionInfo`, `Event`, `EventSignal`, `Terminated`, `firstPeerCommitRemote` - * signature of `makeConnectionHandler` - * moved `InboundGovernorInfoChannel` to IG from InformationChannel - and changed its type to contain `Event`'s. - -### Non-breaking changes - -* Added `terminatingConns` to `ConnectionManagerCounters` - -## 0.18.0.2 -- 2025-07-17 - -### Breaking changes - -### Non-breaking changes - -* dependencies version bounds update for base and QuickCheck - -## 0.18.0.1 -- 2025-06-02 - -### Non-breaking changes - -* properly unmask async exceptions in the CM - -## 0.18.0.0 -- 2025-05-13 - -### Breaking changes - -* `ConnectionHandlerFn` takes an optional `ReadBuffer` for mux socket bearers -* ConnectionManager's `Args` record exposes a `withBuffer` combinator - for working with buffered socket bearers introduced in the network-mux package - -## 0.17.0.0 -- 2025-02-25 - -### Breaking changes - -* Add `miniProtocolStart` to `MiniProtocol` to control starting strategy. -* `Ouroboros.Network.Subscription` removed. -* `Ouroboros.Network.ErrorPolicy` removed. -* APIs removed from `Ouroboros.Network.Socket`: - * `NetworkMutableState` & friends, - * `withServerNode` (see below for a replacement), - * `NetworkServerTracers`, - * `fromSnocket`, - * `beginConnection` -* `Ouroboros.Network.Server.Socket` replaced with a simpler server - implementation in `Test.Ouroboros.Network.Server` (in `ouroboros-network:testlib` component). -* Added `Ouroboros.Network.Server.Simple.with` to run a simple server as a replacement for `Ouroboros.Network.Socket.withServerNode`. - -## 0.16.0.0 -- 2025-02-03 - -### Breaking changes - -* `simpleSingletonVersions`: takes a callback which receives negotiated version data. - -## 0.15.0.0 -- 2025-01-02 - -### Breaking changes - -* `Ouroboros.Network.Subscription` removed. -* `Ouroboros.Network.ErrorPolicy` removed. -* APIs removed from `Ouroboros.Network.Socket`: - * `NetworkMutableState` & friends, - * `withServerNode` and `withServerNode'`, - * `NetworkServerTracers`, - * `fromSnocket`, - * `beginConnection` -* `Ouroboros.Network.Server.Socket` replaced with a simpler server - implementation in `Test.Ouroboros.Network.Server` (in `ouroboros-network:testlib` component). -* Use `IOError` in `BearerInfo`. -* Addapted to `network-mux` changes in https://github.com/IntersectMBO/ouroboros-network/pull/4999 -* Addapted to `network-mux` changes in https://github.com/IntersectMBO/ouroboros-network/pull/4997 -* Removed deprecated `Ouroboros.Network.Channel.{to,from}Channel` functions. -* Renamed `requestOutboundConnection` to `acquireOutboundConnection` and - `unregister{Inbound,Outbound}Connection` to `release{Inbound,Outbound}Connection`. - `AssertionLocation` constructors were renamed as well. -* Added `RawBearer` API (see https://github.com/IntersectMBO/ouroboros-network/pull/4395) -* Connection manager is using `ConnectionId`s to identify connections, this - affects its API. -* Added `connStateSupply` record field to - `Ouroboros.Network.ConnectionManager.Core.Arguments`. -* Renamed modules in `ouroboros-network:testlib`: - `Ouroboros.Network.Test.Orphans -> Test.Ouroboros.Network.Orphans` - `Ouroboros.Network.ConnectionManager.Test.Experiments -> Test.Ouroboros.Network.ConnectionManager.Experiments` - `Ouroboros.Network.ConnectionManager.Test.Timeouts -> Test.Ouroboros.Network.ConnectionManager.Timeouts` - `Ouroboros.Network.ConnectionManager.Test.Utils -> Test.Ouroboros.Network.ConnectionManager.Utils` - `Ouroboros.Network.InboundGovernor.Test.Utils -> Test.Ouroboros.Network.InboundGovernor.Utils` - - -### Non-breaking changes - -* Dropped all node-to-client versions < `NodeToClientV_16`. - -## 0.14.0.0 -- 2024-10-17 - -### Breaking changes - -* Added `createConnectedBufferedChannelsUnbounded`. -* Use `typed-protocols-0.3.0.0`. -* Removed `Ouroboros.Network.Mux.toApplication` -* Renamed `Ouroboros.Network.Mux.mkMiniProtocolBundle` as `mkMiniProtocolInfos` - (its type has changed). -* Added `Ouroboros.Network.Mux.toMiniProtocolInfos`. -* Added `ConnectToArgs` for `Ouroboros.Network.Socket.connectToNode` & friends. -* `Ouroboros.Network.Socket.connectToNode` & friends return result (or an - error) of the first terminated mini-protocol. -* Added `Ouroboros.Network.Socket.connectToNodeWithMux` and - `connectToNodeWithMux'`. They give control over running mux, e.g. one can - start some of the mini-protocols, or implement a re-start policy. -* `Ouroboros.Network.InboundGovernor` module is supposed to be imported - qualified. Type names and record fields were modified. -* Added `Ouroboros.Network.InboundGovernor.Arguments` record type. -* `Ouroboros.Network.Server2` module is supposed to be imported qualified. - Type names and record fields were modified. -* `Ouroboros.Network.ConnectionManager.InformationChannel.OutboundGovernorInfoChannel` was removed. -* `Ouroboros.Network.ConnectionManager.ConnectionManagerArguments`: - `connectionDataFlow` doesn't take `versionNumber` as an argument. -* `Ouroboros.Network.ConnectionManager.Core` must be imported qualified. -* `ConnectionManagerTrace` moved from `Ouroboros.Network.ConnectionManager.Types` - to the `Core` module & renamed as `Trace`. -* RawBearer API (typeclass and instances) added. - -### Non-breaking changes - -* Added tracing on CM connVars for testing purposes. -* Improved haddocks of `Hanshake` protocol codec. - -## 0.13.2.5 -- 2024-10-11 - -### Breaking changes - -### Non-breaking changes - -* bump for version bounds - -## 0.13.2.4 -- 2024-08-27 - -### Non-breaking changes - -* bump for bad ref in chap for 0.13.2.3 - -## 0.13.2.3 -- 2024-08-22 - -### Non-breaking changes - -* version bump for build depends - -## 0.13.2.2 -- 2024-08-07 - -### Non-breaking changes - -* Make it build with ghc-9.10 -* Improve memory footprint of tests by using strict version of STM - -## 0.13.2.1 -- 2024-06-26 - -### Non-breaking changes - -- Fix `InboundGovernorCounters` - -## 0.13.2.0 -- 2024-06-07 - -### Non-breaking changes - -- Fixed `InboundGovernorCounters` tracing frequency -- Bump io-sim and io-classes -- Fixed connection manager transition test - -## 0.13.1.0 -- 2024-05-08 - -### Non-breaking changes - -* New tests -* Using `quickcheck-monoids` - -## 0.13.0.0 -- 2024-05-08 - -### Breaking changes - -* connection-manager: maintain it's own source of randomness for `PrunePolicy`. - The types `PrunPolicy`, `ConnectionManagerArguments` changed. -* server accepts a callback which receives an `STM` action allowing to observe - public part of `InboundGovernorState`. The refactorisation changed how - exceptions are propagated through from the threads run by the server to the - main thread. `InboundGovernorObservableState` was replaced with - `PublicInboundGovernorState`. -* removed the outbound information channel between the connection manager - & outbound governor; the outbound governor now can use the - `PublichInboundGovernorState`. -* Added `serverDebugInboundGovernor` tracer was added to `ServerArguments`. - -## 0.12.0.0 -- 2024-03-15 - -### Breaking changes - -* Let light peer sharing depend on the configured peer sharing flag - -### Non-breaking changes - -* Added `Generic` and `NFData` instance derivations for `NodeToNodeVersion` - data type -* Added `NFData` for `Handshake` protocol related types - -## 0.11.1.0 -- 2024-02-21 - -### Breaking changes - -### Non-breaking changes - -* Fixed correct transition tracing in the case of self connect - -## 0.11.0.0 -- 2024-01-22 - -### Breaking changes - -* Moved `configureOutboundSocket` to `ouroboros-network` (it's not exported - anymore). - -### Non-breaking changes - -* ghc-9.8 support. -* Add Socket.NoDelay option to `configureOutboundSocket` - -## 0.10.2.0 -- 2023-12-14 - -### Non-breaking changes - -* Use `io-sim-1.3.1.0`. - -## 0.10.1.0 -- 2023-11-16 - -### Non-breaking changes - -* Updated code to accommodate changes on `PeerSharing` data type. -* Fixed Server2 [sim test](https://github.com/intersectmbo/ouroboros-network/issues/4607) by synchronizing connection/disconnection events. -* Changed connection manager `readState` function to be in `STM` instead of `m` -* Added `waitForOutboundDemotion` function to Connection - Manager's API -* Use `io-sim-1.3.0.0`. - -## 0.10.0.1 -- 2023-11-02 - -### Non-breaking changes - -* Updated code to accommodate changes on `PeerSharing` data type. -* Updated version bounds. - -## 0.10.0.0 -- 2023-10-26 - -### Breaking changes - -* `ResourceException` is now an existential type. - -### Non-breaking changes - -* An inbound peer is considered hot if any hot protocol is running. -* Split `test` component into `io-tests` and `sim-tests`. -* `demo-ping-pong`: improved tracer. -* Fixed a bug in `connection-manager` which could result in leaking - a connection. - -## 0.9.0.0 -- 2023-08-21 - -### Breaking changes - -* Pass `Maybe InformationChannel` to connection manger. This gives us a way to - disable light peer sharing. - -### Non-breaking changes - -## 0.8.0.0 -- 2023-08-09 - -### Breaking changes - -* `MuxProtocolBundle` type alias was removed, since it was just reduced to - a list of 'MiniProtocol's. - -* Added `ExpandedInitiatorContext`, `MinimalInitiatorContext` and - `ResponderInitiatorContext` types in a new module: - `Ouroboros.Network.Context`. The module also re-exports `ConnectionId`, - `IsBigLedgerPeer` and `ControlMessageSTM` thus an unqualified import might - cause some warnings. - -* `RunMiniProtocol` now contains callbacks which receive a context. The type - is polymorphic over initiator and responder contexts. We also provide type - aliases for `RunMiniProtocolWithExpandedCtx` and - `RunMiniProtocolWithMinimalCtx` which instatiate initiator and responider - contexts. - -* Added `OuroborosBundleWithExpandedCtx` and `OuroborosBundleWithMinimalCtx` - type aliases. - -* Added `OuroborosApplicationWithMinimalCtx` type aliases. - -* Added `contramMapInitiatorCtx` which contramaps the initiator context of an - `OuroborosApplication`. - -* Added `fromOuroborosBundle` which creates `OuroborosApplication` from - `OuroborosBundle` by forgetting the hot / warm / established distinction - between all mini-protocols. - -* Removed `MuxBundle` and `mkMuxApplicationBundle` which is no longer needed. - -* Due to the above changes the following APIs changed their type signatures: - - - `Ouroboros.Network.Socket.connectToNode` - - `Ouroboros.Network.Socket.connectToNode'` - - `Ouroboros.Network.Socket.connectToNodeSocket` - - `Ouroboros.Network.Socket.SomeResponderApplication` - - `Ouroboros.Network.Socket.withServerNode` - - inbound governor API - -* `MuxPeer` changed it's kind and it was renamed to `MiniProtocolCb`, the old - type is still provided but deprecated. The `MuxPeerRaw` constructor was - renamed to `MiniProtocolCb` (the old one is still provided but deprecated). - `MuxPeer` and `MuxPeerPipelined` constructors also changed its type and are - now deprecated. Use `mkMiniProtocolCbFromPeer` and - `mkMiniProtocolCbFromPeerPipelined` instead. - - Also note that even the deprecated constructors have changed their types. - -* `runMuxPeer` change its type but also is now deprecated in favour of `runMiniProtocolCb`. The latter - receives two arguments: the context and `Network.Mux.Channel.Channel` rather - than `Ouroboros.Network.Channel.Channel` (no need to use - `Ouroboros.Network.Channel.fromChannel`). `runMuxPeer` accepts the context (added argument) and - `Ouroboros.Network.Channel.Channel`. - -### Non-breaking changes - -* Added `Functor` instance for `ConnectionId`. - -## 0.7.0.0 -- 2023-07-17 - -### Breaking changes - -* light peer sharing: - * Added `cmGetPeerSharing` field to `ConnectionManagerArguments`. - * Added `getProtocolPeerSharing` field to `DataFlowProtocolData` record. - * Renamed `serverControlChannel` as `serverInboundInfoChannel` of the `ServerArguments` record. - * Moved `OurboundGovernorInfoChannel` to `ouroboros-network`. - -### Non-breaking changes - -* Fixed query shutdown timeout in the legacy (non-p2p) mode (20s). - -## 0.6.0.1 -- 2023-05-15 - -* Updated to use `ouroboros-network-api-0.5.0.0`. - -## 0.6.0.0 -- 2023-05-08 - -### Breaking changes - -* Handshake support for querying: - * Use `ouroboros-network-api-0.4.0.0` - * Added `haQueryVersion` to `HandshakeArguments` - * `handshakeServerPeer` recieves extra argument `vData -> Bool` - * Added `MsgQueryReply` to `Handshake` mini-protocol. - * Added `Ouroboros.Network.Protocol.Handshake.Client.handshakeCleintPeerTestVersions` - * Added `HandshakeResult` and `HandshakeException` types. - -## 0.5.0.0 -- 2023-04-28 - -### Breaking changes - -* Use `io-classes-1.1`. - -### Non-breaking changes - -* `ghc-9.4` and `ghc-9.6` compatibility. - -## 0.4.0.0 -- 2023-04-19 - -### Non-breaking changes - -- Fix interop problems between NonP2P and P2P nodes (PR #4465) -- Fix incorrect transition order (issue #4370) - -### Breaking - -- Removed `TrImpossibleConnection` trace (PR #4385) -- Peer Sharing integration - -## 0.3.0.0 -- 2023-01-25 - -* Removed `toBearer` method of `Snocket`, instead the `Ouroboros.Network.Snocket` module exposes `makeSocketBearer`, `makeLocalBearer` and re-exports `MakeBearer` newtype wrapper. -* Update dependencies after repository restructure. -* Added `ipv6` cabal flag. -* Support `ghc-9.2` - -## 0.2.0.0 -- YYYY-MM-DD - -* Export `WithAddr` from `Simulation.Network.Snocket` -* Use `io-sim-0.3.0.0` -* `ExceptionInHandler` is an existential type which makes it easier to catch. -* Connection handler rethrows exceptions wrapped in `ExceptionInHandler`. -* We don't configure sockets in `bind` method anymore, many functions accept an argument to configure a socket, e.g. `ConnectionManagerArguments`. Added `configureSocket`, `configureSystemdSocket` and `configureOutboundSocket` functions in `Ouroboros.Network.Socket` module. Also added `SystemdSocketTracer` -* Removed `StructLinger` (it's available from the `network-3.1.2.2` package) -* Renamed `TrError` as `TrConnectionHandlerError` which is a constructor of `ConnectionHandlerTrace` type. -* Changed `Show` instance of `TestAddress` -* Removed `TrUnknownConnection` trace (connection-manager). -* Changed type of `serverInboundIdleTimeout` field of `ServerArguments` from `DiffTime` to `Maybe DiffTime`. -* Renamed `Ouroboros.Network.Mux.TokProtocolTemperature` as `Ouroboros.Network.Mux.SingProtocolTemperature`. -* Renamed `Ouroboros.Network.Mux.Bundle` as `Ouroboros.Network.Mux.TemperatureBundle`. -* Connection manager's `ControlChannel` type changed (internal). - -## 0.1.0.0 -- YYYY-mm-dd - -* First version. Released on an unsuspecting world. diff --git a/ouroboros-network-framework/LICENSE b/ouroboros-network-framework/LICENSE deleted file mode 100644 index f433b1a53f5..00000000000 --- a/ouroboros-network-framework/LICENSE +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/ouroboros-network-framework/NOTICE b/ouroboros-network-framework/NOTICE deleted file mode 100644 index 3efdc24424e..00000000000 --- a/ouroboros-network-framework/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/ouroboros-network-framework/Setup.hs b/ouroboros-network-framework/Setup.hs deleted file mode 100644 index 9a994af677b..00000000000 --- a/ouroboros-network-framework/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/ouroboros-network-framework/changelog.d/scriv.ini b/ouroboros-network-framework/changelog.d/scriv.ini deleted file mode 100644 index b3f06f41b39..00000000000 --- a/ouroboros-network-framework/changelog.d/scriv.ini +++ /dev/null @@ -1,15 +0,0 @@ -[scriv] -format = md -insert_marker = Changelog entries -md_header_level = 2 -version = literal: ouroboros-network-framework.cabal: version -categories = Breaking, Non-Breaking -start_marker = scriv-insert-here -end_marker = scriv-end-here -fragment_directory = changelog.d -ghrel_template = {{body}} -main_branches = main -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = CHANGELOG.${config:format} -skip_fragments = README.* -entry_title_template = {%% if version %%}{{ version }} -- {%% endif %%}{{ date.strftime('%%Y-%%m-%%d') }} diff --git a/ouroboros-network-framework/ouroboros-network-framework.cabal b/ouroboros-network-framework/ouroboros-network-framework.cabal deleted file mode 100644 index d5eb85bf063..00000000000 --- a/ouroboros-network-framework/ouroboros-network-framework.cabal +++ /dev/null @@ -1,310 +0,0 @@ -cabal-version: 3.0 -name: ouroboros-network-framework -version: 0.20.0.0 -synopsis: Ouroboros network framework -description: Ouroboros network framework. -license: Apache-2.0 -license-files: - LICENSE - NOTICE - -copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect -author: Alexander Vieth, Duncan Coutts, Marcin Szamotulski -maintainer: marcin.szamotulski@iohk.io -category: Network -build-type: Simple -extra-doc-files: CHANGELOG.md - -flag ipv6 - description: Enable IPv6 test cases - manual: True - -- Default to False since travis lacks IPv6 support - default: False - -library - exposed-modules: - Data.Cache - Data.Wedge - NoThunks.Class.Orphans - Ouroboros.Network.Channel - Ouroboros.Network.ConnectionHandler - Ouroboros.Network.ConnectionId - Ouroboros.Network.ConnectionManager.ConnMap - Ouroboros.Network.ConnectionManager.Core - Ouroboros.Network.ConnectionManager.State - Ouroboros.Network.ConnectionManager.Types - Ouroboros.Network.Context - Ouroboros.Network.Driver - Ouroboros.Network.Driver.Limits - Ouroboros.Network.Driver.Simple - Ouroboros.Network.Driver.Stateful - Ouroboros.Network.IOManager - Ouroboros.Network.InboundGovernor - Ouroboros.Network.InboundGovernor.InformationChannel - Ouroboros.Network.InboundGovernor.State - Ouroboros.Network.Mux - Ouroboros.Network.MuxMode - Ouroboros.Network.Protocol.Handshake - Ouroboros.Network.Protocol.Handshake.Client - Ouroboros.Network.Protocol.Handshake.Codec - Ouroboros.Network.Protocol.Handshake.Server - Ouroboros.Network.Protocol.Handshake.Type - Ouroboros.Network.Protocol.Handshake.Unversioned - Ouroboros.Network.Protocol.Handshake.Version - Ouroboros.Network.RawBearer - Ouroboros.Network.RethrowPolicy - Ouroboros.Network.Server - Ouroboros.Network.Server.ConnectionTable - Ouroboros.Network.Server.RateLimiting - Ouroboros.Network.Server.Simple - Ouroboros.Network.Snocket - Ouroboros.Network.Socket - Simulation.Network.Snocket - - -- other-extensions: - build-depends: - -- ^ only to derive nothunk instances - Win32-network ^>=0.2, - base >=4.12 && <4.22, - bytestring >=0.10 && <0.13, - cardano-strict-containers, - cborg >=0.2.1 && <0.3, - containers >=0.5 && <0.8, - contra-tracer, - deepseq, - hashable, - io-classes:{io-classes, si-timers, strict-stm} ^>=1.8.0.1, - monoidal-synchronisation ^>=0.1.0.6, - network ^>=3.2.7, - network-mux ^>=0.9.1, - nothunks, - nothunks ^>=0.1.4 || ^>=0.2, - ouroboros-network-api ^>=0.17, - ouroboros-network-testing, - psqueues, - quiet, - random ^>=1.2, - text, - typed-protocols:{typed-protocols, cborg, stateful} ^>=1.1, - - if os(windows) - build-depends: Win32 >=2.5.4.1 && <3.0 - hs-source-dirs: src - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages - -library testlib - visibility: public - hs-source-dirs: testlib - exposed-modules: - Test.Ouroboros.Network.ConnectionManager.Experiments - Test.Ouroboros.Network.ConnectionManager.Timeouts - Test.Ouroboros.Network.ConnectionManager.Utils - Test.Ouroboros.Network.InboundGovernor.Utils - Test.Ouroboros.Network.Orphans - Test.Ouroboros.Network.RawBearer.Utils - - other-modules: - build-depends: - QuickCheck >=2.16, - base >=4.14 && <4.22, - bytestring, - cborg, - containers, - contra-tracer, - hashable, - io-classes:{io-classes, si-timers, strict-stm}, - io-sim, - network-mux, - ouroboros-network-api, - ouroboros-network-framework, - ouroboros-network-testing, - random, - serialise, - typed-protocols:{typed-protocols, examples}, - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages - -test-suite sim-tests - type: exitcode-stdio-1.0 - main-is: Main.hs - hs-source-dirs: sim-tests - other-modules: - Test.Ouroboros.Network.ConnectionManager - Test.Ouroboros.Network.RateLimiting - Test.Ouroboros.Network.RawBearer - Test.Ouroboros.Network.Server.Sim - Test.Simulation.Network.Snocket - - build-depends: - QuickCheck >=2.16, - base >=4.14 && <4.22, - bytestring, - cborg, - containers, - contra-tracer, - io-classes:{io-classes, si-timers, strict-stm}, - io-sim, - monoidal-synchronisation, - network-mux, - ouroboros-network-api, - ouroboros-network-framework, - ouroboros-network-framework:testlib, - ouroboros-network-testing, - pretty-simple, - psqueues, - quickcheck-instances, - quiet, - random, - serialise, - tasty, - tasty-quickcheck, - text, - typed-protocols:{typed-protocols, cborg, examples}, - with-utf8, - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -rtsopts - -threaded - -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages - - if flag(ipv6) - cpp-options: -DOUROBOROS_NETWORK_IPV6 - -test-suite io-tests - type: exitcode-stdio-1.0 - main-is: Main.hs - hs-source-dirs: io-tests - other-modules: - Test.Ouroboros.Network.Driver - Test.Ouroboros.Network.RawBearer - Test.Ouroboros.Network.Server.IO - Test.Ouroboros.Network.Socket - - build-depends: - QuickCheck >=2.16, - base >=4.14 && <4.22, - bytestring, - contra-tracer, - directory, - io-classes:{io-classes, si-timers, strict-stm}, - io-sim, - monoidal-synchronisation, - network, - network-mux, - ouroboros-network-api, - ouroboros-network-framework, - ouroboros-network-framework:testlib, - random, - tasty, - tasty-quickcheck, - time, - typed-protocols:{typed-protocols, examples, stateful}, - with-utf8, - - if os(windows) - build-depends: Win32-network <0.3 - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -rtsopts - -threaded - -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages - -executable demo-ping-pong - hs-source-dirs: demo - main-is: ping-pong.hs - build-depends: - async, - base >=4.14 && <4.22, - bytestring, - contra-tracer, - directory, - network-mux, - ouroboros-network-api, - ouroboros-network-framework, - typed-protocols:examples, - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -Wall - -threaded - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages - -executable demo-connection-manager - hs-source-dirs: demo - main-is: connection-manager.hs - build-depends: - base >=4.14 && <4.22, - bytestring, - contra-tracer, - hashable, - io-classes:{io-classes, si-timers, strict-stm}, - network, - network-mux, - optparse-applicative, - ouroboros-network-api, - ouroboros-network-framework, - random, - typed-protocols:{typed-protocols, examples}, - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -Wall - -threaded - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages diff --git a/ouroboros-network-framework/test/Main.hs b/ouroboros-network-framework/test/Main.hs deleted file mode 100644 index d3acfde56b8..00000000000 --- a/ouroboros-network-framework/test/Main.hs +++ /dev/null @@ -1,30 +0,0 @@ -module Main (main) where - -import Test.Tasty - -import Test.Ouroboros.Network.ConnectionManager qualified as ConnectionManager -import Test.Ouroboros.Network.Driver qualified as Driver -import Test.Ouroboros.Network.RateLimiting qualified as RateLimiting -import Test.Ouroboros.Network.RawBearer qualified as RawBearer -import Test.Ouroboros.Network.Server2 qualified as Server2 -import Test.Ouroboros.Network.Socket qualified as Socket -import Test.Ouroboros.Network.Subscription qualified as Subscription -import Test.Simulation.Network.Snocket qualified as Snocket - -main :: IO () -main = defaultMain tests - -tests :: TestTree -tests = - testGroup "ouroboros-network-framework" - [ ConnectionManager.tests - , Driver.tests - , Server2.tests - , Socket.tests - , Subscription.tests - , RateLimiting.tests - , Snocket.tests - , RawBearer.tests - ] - - diff --git a/ouroboros-network-framework/demo/connection-manager.hs b/ouroboros-network/demo/connection-manager.hs similarity index 100% rename from ouroboros-network-framework/demo/connection-manager.hs rename to ouroboros-network/demo/connection-manager.hs diff --git a/ouroboros-network-framework/demo/ping-pong.hs b/ouroboros-network/demo/ping-pong.hs similarity index 100% rename from ouroboros-network-framework/demo/ping-pong.hs rename to ouroboros-network/demo/ping-pong.hs diff --git a/ouroboros-network-framework/io-tests/Main.hs b/ouroboros-network/framework/io-tests/Main.hs similarity index 100% rename from ouroboros-network-framework/io-tests/Main.hs rename to ouroboros-network/framework/io-tests/Main.hs diff --git a/ouroboros-network-framework/io-tests/Test/Ouroboros/Network/Driver.hs b/ouroboros-network/framework/io-tests/Test/Ouroboros/Network/Driver.hs similarity index 100% rename from ouroboros-network-framework/io-tests/Test/Ouroboros/Network/Driver.hs rename to ouroboros-network/framework/io-tests/Test/Ouroboros/Network/Driver.hs diff --git a/ouroboros-network-framework/io-tests/Test/Ouroboros/Network/RawBearer.hs b/ouroboros-network/framework/io-tests/Test/Ouroboros/Network/RawBearer.hs similarity index 100% rename from ouroboros-network-framework/io-tests/Test/Ouroboros/Network/RawBearer.hs rename to ouroboros-network/framework/io-tests/Test/Ouroboros/Network/RawBearer.hs diff --git a/ouroboros-network-framework/io-tests/Test/Ouroboros/Network/Server/IO.hs b/ouroboros-network/framework/io-tests/Test/Ouroboros/Network/Server/IO.hs similarity index 100% rename from ouroboros-network-framework/io-tests/Test/Ouroboros/Network/Server/IO.hs rename to ouroboros-network/framework/io-tests/Test/Ouroboros/Network/Server/IO.hs diff --git a/ouroboros-network-framework/io-tests/Test/Ouroboros/Network/Socket.hs b/ouroboros-network/framework/io-tests/Test/Ouroboros/Network/Socket.hs similarity index 100% rename from ouroboros-network-framework/io-tests/Test/Ouroboros/Network/Socket.hs rename to ouroboros-network/framework/io-tests/Test/Ouroboros/Network/Socket.hs diff --git a/ouroboros-network-framework/io-tests/Test/Ouroboros/Network/Subscription.hs b/ouroboros-network/framework/io-tests/Test/Ouroboros/Network/Subscription.hs similarity index 100% rename from ouroboros-network-framework/io-tests/Test/Ouroboros/Network/Subscription.hs rename to ouroboros-network/framework/io-tests/Test/Ouroboros/Network/Subscription.hs diff --git a/ouroboros-network-framework/src/Data/Cache.hs b/ouroboros-network/framework/lib/Data/Cache.hs similarity index 100% rename from ouroboros-network-framework/src/Data/Cache.hs rename to ouroboros-network/framework/lib/Data/Cache.hs diff --git a/ouroboros-network-framework/src/Data/Wedge.hs b/ouroboros-network/framework/lib/Data/Wedge.hs similarity index 100% rename from ouroboros-network-framework/src/Data/Wedge.hs rename to ouroboros-network/framework/lib/Data/Wedge.hs diff --git a/ouroboros-network-framework/src/NoThunks/Class/Orphans.hs b/ouroboros-network/framework/lib/NoThunks/Class/Orphans.hs similarity index 100% rename from ouroboros-network-framework/src/NoThunks/Class/Orphans.hs rename to ouroboros-network/framework/lib/NoThunks/Class/Orphans.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Channel.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Channel.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Channel.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Channel.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/ConnectionHandler.hs b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionHandler.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/ConnectionHandler.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/ConnectionHandler.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/ConnectionId.hs b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionId.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/ConnectionId.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/ConnectionId.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/ConnMap.hs b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/ConnMap.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/ConnMap.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/ConnMap.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/Core.hs b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Core.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/Core.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Core.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/State.hs b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/State.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/State.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/State.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/Types.hs b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Types.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/Types.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Types.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Context.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Context.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Context.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Context.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Driver.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Driver.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Driver.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Driver.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Driver/Limits.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Driver/Limits.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Driver/Limits.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Driver/Limits.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Driver/Simple.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Driver/Simple.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Driver/Simple.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Driver/Simple.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Driver/Stateful.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Driver/Stateful.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Driver/Stateful.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Driver/Stateful.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/IOManager.hs b/ouroboros-network/framework/lib/Ouroboros/Network/IOManager.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/IOManager.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/IOManager.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/InboundGovernor.hs b/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/InboundGovernor.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/InboundGovernor/InformationChannel.hs b/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor/InformationChannel.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/InboundGovernor/InformationChannel.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor/InformationChannel.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/InboundGovernor/State.hs b/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor/State.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/InboundGovernor/State.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor/State.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Mux.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Mux.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Mux.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Mux.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/MuxMode.hs b/ouroboros-network/framework/lib/Ouroboros/Network/MuxMode.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/MuxMode.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/MuxMode.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Client.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Client.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Client.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Client.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Codec.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Codec.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Server.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Server.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Server.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Server.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Type.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Type.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Type.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Type.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Unversioned.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Unversioned.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Unversioned.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Unversioned.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Version.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Version.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Version.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Version.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/RawBearer.hs b/ouroboros-network/framework/lib/Ouroboros/Network/RawBearer.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/RawBearer.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/RawBearer.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/RethrowPolicy.hs b/ouroboros-network/framework/lib/Ouroboros/Network/RethrowPolicy.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/RethrowPolicy.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/RethrowPolicy.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Server.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Server.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Server.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Server.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Server/ConnectionTable.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Server/ConnectionTable.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Server/ConnectionTable.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Server/ConnectionTable.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Server/RateLimiting.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Server/RateLimiting.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Server/RateLimiting.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Server/RateLimiting.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Server/Simple.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Server/Simple.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Server/Simple.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Server/Simple.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Snocket.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Snocket.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Snocket.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Snocket.hs diff --git a/ouroboros-network-framework/src/Ouroboros/Network/Socket.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Socket.hs similarity index 100% rename from ouroboros-network-framework/src/Ouroboros/Network/Socket.hs rename to ouroboros-network/framework/lib/Ouroboros/Network/Socket.hs diff --git a/ouroboros-network-framework/src/Simulation/Network/Snocket.hs b/ouroboros-network/framework/lib/Simulation/Network/Snocket.hs similarity index 100% rename from ouroboros-network-framework/src/Simulation/Network/Snocket.hs rename to ouroboros-network/framework/lib/Simulation/Network/Snocket.hs diff --git a/ouroboros-network-framework/sim-tests/Main.hs b/ouroboros-network/framework/sim-tests/Main.hs similarity index 100% rename from ouroboros-network-framework/sim-tests/Main.hs rename to ouroboros-network/framework/sim-tests/Main.hs diff --git a/ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs similarity index 100% rename from ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs rename to ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs diff --git a/ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/RateLimiting.hs b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/RateLimiting.hs similarity index 100% rename from ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/RateLimiting.hs rename to ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/RateLimiting.hs diff --git a/ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/RawBearer.hs b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/RawBearer.hs similarity index 100% rename from ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/RawBearer.hs rename to ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/RawBearer.hs diff --git a/ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs similarity index 100% rename from ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs rename to ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs diff --git a/ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/Subscription.hs b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/Subscription.hs similarity index 100% rename from ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/Subscription.hs rename to ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/Subscription.hs diff --git a/ouroboros-network-framework/sim-tests/Test/Simulation/Network/Snocket.hs b/ouroboros-network/framework/sim-tests/Test/Simulation/Network/Snocket.hs similarity index 100% rename from ouroboros-network-framework/sim-tests/Test/Simulation/Network/Snocket.hs rename to ouroboros-network/framework/sim-tests/Test/Simulation/Network/Snocket.hs diff --git a/ouroboros-network-framework/testlib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs b/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs similarity index 100% rename from ouroboros-network-framework/testlib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs rename to ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs diff --git a/ouroboros-network-framework/testlib/Test/Ouroboros/Network/ConnectionManager/Timeouts.hs b/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Timeouts.hs similarity index 100% rename from ouroboros-network-framework/testlib/Test/Ouroboros/Network/ConnectionManager/Timeouts.hs rename to ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Timeouts.hs diff --git a/ouroboros-network-framework/testlib/Test/Ouroboros/Network/ConnectionManager/Utils.hs b/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Utils.hs similarity index 100% rename from ouroboros-network-framework/testlib/Test/Ouroboros/Network/ConnectionManager/Utils.hs rename to ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Utils.hs diff --git a/ouroboros-network-framework/testlib/Test/Ouroboros/Network/InboundGovernor/Utils.hs b/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/InboundGovernor/Utils.hs similarity index 100% rename from ouroboros-network-framework/testlib/Test/Ouroboros/Network/InboundGovernor/Utils.hs rename to ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/InboundGovernor/Utils.hs diff --git a/ouroboros-network-framework/testlib/Test/Ouroboros/Network/Orphans.hs b/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/Orphans.hs similarity index 100% rename from ouroboros-network-framework/testlib/Test/Ouroboros/Network/Orphans.hs rename to ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/Orphans.hs diff --git a/ouroboros-network-framework/testlib/Test/Ouroboros/Network/RawBearer/Utils.hs b/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/RawBearer/Utils.hs similarity index 100% rename from ouroboros-network-framework/testlib/Test/Ouroboros/Network/RawBearer/Utils.hs rename to ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/RawBearer/Utils.hs diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 79b9b49cbdd..124decd318f 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -26,6 +26,12 @@ flag cddl -- These tests need the cddl and the cbor-diag Ruby-package default: True +flag ipv6 + description: Enable IPv6 test cases + manual: True + -- Default to False since travis lacks IPv6 support + default: False + source-repository head type: git location: https://github.com/intersectmbo/ouroboros-network @@ -164,9 +170,8 @@ library network ^>=3.2.7, network-mux, nothunks, - ouroboros-network:protocols ^>=0.23, + ouroboros-network:{framework, protocols} ^>=0.23, ouroboros-network-api ^>=0.17, - ouroboros-network-framework ^>=0.20, psqueues >=0.2.3 && <0.3, random, strict-checked-vars ^>=0.2, @@ -180,6 +185,201 @@ library if flag(asserts) ghc-options: -fno-ignore-asserts +library framework + import: ghc-options + visibility: public + hs-source-dirs: framework/lib + exposed-modules: + Data.Cache + Data.Wedge + NoThunks.Class.Orphans + Ouroboros.Network.Channel + Ouroboros.Network.ConnectionHandler + Ouroboros.Network.ConnectionId + Ouroboros.Network.ConnectionManager.ConnMap + Ouroboros.Network.ConnectionManager.Core + Ouroboros.Network.ConnectionManager.State + Ouroboros.Network.ConnectionManager.Types + Ouroboros.Network.Context + Ouroboros.Network.Driver + Ouroboros.Network.Driver.Limits + Ouroboros.Network.Driver.Simple + Ouroboros.Network.Driver.Stateful + Ouroboros.Network.IOManager + Ouroboros.Network.InboundGovernor + Ouroboros.Network.InboundGovernor.InformationChannel + Ouroboros.Network.InboundGovernor.State + Ouroboros.Network.Mux + Ouroboros.Network.MuxMode + Ouroboros.Network.Protocol.Handshake + Ouroboros.Network.Protocol.Handshake.Client + Ouroboros.Network.Protocol.Handshake.Codec + Ouroboros.Network.Protocol.Handshake.Server + Ouroboros.Network.Protocol.Handshake.Type + Ouroboros.Network.Protocol.Handshake.Unversioned + Ouroboros.Network.Protocol.Handshake.Version + Ouroboros.Network.RawBearer + Ouroboros.Network.RethrowPolicy + Ouroboros.Network.Server + Ouroboros.Network.Server.ConnectionTable + Ouroboros.Network.Server.RateLimiting + Ouroboros.Network.Server.Simple + Ouroboros.Network.Snocket + Ouroboros.Network.Socket + Simulation.Network.Snocket + + -- other-extensions: + build-depends: + -- ^ only to derive nothunk instances + Win32-network ^>=0.2, + base >=4.12 && <4.22, + bytestring >=0.10 && <0.13, + cardano-strict-containers, + cborg >=0.2.1 && <0.3, + containers >=0.5 && <0.8, + contra-tracer, + deepseq, + hashable, + io-classes:{io-classes, si-timers, strict-stm} ^>=1.8.0.1, + monoidal-synchronisation ^>=0.1.0.6, + network ^>=3.2.7, + network-mux ^>=0.9.1, + nothunks, + nothunks ^>=0.1.4 || ^>=0.2, + ouroboros-network-api ^>=0.17, + ouroboros-network-testing, + psqueues, + quiet, + random ^>=1.2, + text, + typed-protocols:{typed-protocols, cborg, stateful} ^>=1.1, + + if os(windows) + build-depends: Win32 >=2.5.4.1 && <3.0 + hs-source-dirs: framework + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + +library framework-tests-lib + import: ghc-options + visibility: public + hs-source-dirs: framework/tests-lib + exposed-modules: + Test.Ouroboros.Network.ConnectionManager.Experiments + Test.Ouroboros.Network.ConnectionManager.Timeouts + Test.Ouroboros.Network.ConnectionManager.Utils + Test.Ouroboros.Network.InboundGovernor.Utils + Test.Ouroboros.Network.Orphans + Test.Ouroboros.Network.RawBearer.Utils + + other-modules: + build-depends: + QuickCheck >=2.16, + base >=4.14 && <4.22, + bytestring, + cborg, + containers, + contra-tracer, + hashable, + io-classes:{io-classes, si-timers, strict-stm}, + io-sim, + network-mux, + ouroboros-network:framework, + ouroboros-network-api, + ouroboros-network-testing, + random, + serialise, + typed-protocols:{typed-protocols, examples}, + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + +test-suite framework-sim-tests + import: ghc-options + type: exitcode-stdio-1.0 + main-is: Main.hs + hs-source-dirs: framework/sim-tests + other-modules: + Test.Ouroboros.Network.ConnectionManager + Test.Ouroboros.Network.RateLimiting + Test.Ouroboros.Network.RawBearer + Test.Ouroboros.Network.Server.Sim + Test.Simulation.Network.Snocket + + build-depends: + QuickCheck >=2.16, + base >=4.14 && <4.22, + bytestring, + cborg, + containers, + contra-tracer, + io-classes:{io-classes, si-timers, strict-stm}, + io-sim, + monoidal-synchronisation, + network-mux, + ouroboros-network:{framework, framework-tests-lib}, + ouroboros-network-api, + ouroboros-network-testing, + pretty-simple, + psqueues, + quickcheck-instances, + quiet, + random, + serialise, + tasty, + tasty-quickcheck, + text, + typed-protocols:{typed-protocols, cborg, examples}, + with-utf8, + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + ghc-options: + -rtsopts + -threaded + + if flag(ipv6) + cpp-options: -DOUROBOROS_NETWORK_IPV6 + +test-suite framework-io-tests + import: ghc-options + type: exitcode-stdio-1.0 + main-is: Main.hs + hs-source-dirs: framework/io-tests + other-modules: + Test.Ouroboros.Network.Driver + Test.Ouroboros.Network.RawBearer + Test.Ouroboros.Network.Server.IO + Test.Ouroboros.Network.Socket + + build-depends: + QuickCheck >=2.16, + base >=4.14 && <4.22, + bytestring, + contra-tracer, + directory, + io-classes:{io-classes, si-timers, strict-stm}, + io-sim, + monoidal-synchronisation, + network, + network-mux, + ouroboros-network:{framework, framework-tests-lib}, + ouroboros-network-api, + random, + tasty, + tasty-quickcheck, + time, + typed-protocols:{typed-protocols, examples, stateful}, + with-utf8, + + if os(windows) + build-depends: Win32-network <0.3 + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + ghc-options: + -rtsopts + -threaded + library orphan-instances import: ghc-options visibility: public @@ -224,16 +424,73 @@ library orphan-instances iproute, network, network-mux, - ouroboros-network:{ouroboros-network, cardano-diffusion}, - ouroboros-network:protocols, + ouroboros-network:{ouroboros-network, cardano-diffusion, framework, protocols}, ouroboros-network-api ^>=0.17, - ouroboros-network-framework ^>=0.20, text, typed-protocols, if flag(asserts) ghc-options: -fno-ignore-asserts +executable demo-ping-pong + hs-source-dirs: demo + main-is: ping-pong.hs + build-depends: + async, + base >=4.14 && <4.22, + bytestring, + contra-tracer, + directory, + network-mux, + ouroboros-network:framework, + ouroboros-network-api, + typed-protocols:examples, + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + ghc-options: + -Wall + -threaded + -Wcompat + -Wincomplete-uni-patterns + -Wincomplete-record-updates + -Wpartial-fields + -Widentities + -Wredundant-constraints + -Wno-unticked-promoted-constructors + -Wunused-packages + +executable demo-connection-manager + hs-source-dirs: demo + main-is: connection-manager.hs + build-depends: + base >=4.14 && <4.22, + bytestring, + contra-tracer, + hashable, + io-classes:{io-classes, si-timers, strict-stm}, + network, + network-mux, + optparse-applicative, + ouroboros-network:framework, + ouroboros-network-api, + random, + typed-protocols:{typed-protocols, examples}, + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + ghc-options: + -Wall + -threaded + -Wcompat + -Wincomplete-uni-patterns + -Wincomplete-record-updates + -Wpartial-fields + -Widentities + -Wredundant-constraints + -Wno-unticked-promoted-constructors + -Wunused-packages + library cardano-diffusion import: ghc-options visibility: public @@ -295,9 +552,8 @@ library cardano-diffusion monoidal-synchronisation, network ^>=3.2.7, network-mux, - ouroboros-network:{ouroboros-network, protocols}, + ouroboros-network:{ouroboros-network, framework, protocols}, ouroboros-network-api ^>=0.17, - ouroboros-network-framework ^>=0.20, random, typed-protocols:{typed-protocols, stateful} ^>=1.1, @@ -459,9 +715,9 @@ library protocols-tests-lib io-sim, network, network-mux, + ouroboros-network:framework, ouroboros-network:protocols, ouroboros-network-api, - ouroboros-network-framework, ouroboros-network-mock, ouroboros-network-testing, pipes, @@ -523,9 +779,9 @@ test-suite protocols-cddl filepath, mtl, network, + ouroboros-network:framework, ouroboros-network:{protocols, protocols-tests-lib}, ouroboros-network-api, - ouroboros-network-framework, ouroboros-network-mock, process-extras, quickcheck-instances, @@ -556,9 +812,9 @@ test-suite protocols-bench containers, deepseq, network, + ouroboros-network:{framework, protocols, protocols-tests-lib}, ouroboros-network:{protocols, protocols-tests-lib}, ouroboros-network-api, - ouroboros-network-framework, tasty-bench, typed-protocols:{typed-protocols, stateful}, @@ -605,11 +861,8 @@ library testlib network, network-mux, nothunks, - ouroboros-network:{ouroboros-network, cardano-diffusion, orphan-instances}, - ouroboros-network:{protocols, protocols-tests-lib}, + ouroboros-network:{ouroboros-network, cardano-diffusion, framework, framework-tests-lib, orphan-instances, protocols, protocols-tests-lib}, ouroboros-network-api, - ouroboros-network-framework, - ouroboros-network-framework:testlib, ouroboros-network-mock, ouroboros-network-testing ^>=0.8.3, pipes, @@ -676,7 +929,7 @@ test-suite sim-tests main-is: Main.hs build-depends: base >=4.14 && <4.22, - ouroboros-network:{protocols-tests-lib, testlib}, + ouroboros-network:{protocols, protocols-tests-lib, testlib}, tasty, with-utf8, @@ -713,9 +966,9 @@ test-suite io-tests network, network-mux, ouroboros-network:cardano-diffusion, + ouroboros-network:{framework, protocols, protocols-tests-lib}, ouroboros-network:{protocols, protocols-tests-lib}, ouroboros-network-api, - ouroboros-network-framework, ouroboros-network-mock, ouroboros-network-testing ^>=0.8.1, serialise, @@ -752,10 +1005,8 @@ executable demo-chain-sync io-classes:{si-timers, strict-stm}, network-mux, optparse-applicative, - ouroboros-network:{ouroboros-network, cardano-diffusion}, - ouroboros-network:protocols, + ouroboros-network:{ouroboros-network, cardano-diffusion, framework, protocols}, ouroboros-network-api, - ouroboros-network-framework, ouroboros-network-mock, random, serialise, From 83bb0d5a34b839195454d356a6f9622556bbf3d8 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Mon, 15 Sep 2025 18:01:34 +0200 Subject: [PATCH 04/24] Moved ouroboros-network-mock to ouroboros-network:mock * `ouroboros-newtork-mock` -> `ouroboros-network:mock` in `mock` --- cabal.project | 1 - ouroboros-network-mock/CHANGELOG.md | 42 ----- ouroboros-network-mock/LICENSE | 177 ------------------ ouroboros-network-mock/NOTICE | 14 -- ouroboros-network-mock/changelog.d/scriv.ini | 15 -- .../ouroboros-network-mock.cabal | 59 ------ .../mock}/Ouroboros/Network/Mock/Chain.hs | 0 .../Ouroboros/Network/Mock/ConcreteBlock.hs | 0 .../Ouroboros/Network/Mock/ProducerState.hs | 0 ouroboros-network/ouroboros-network.cabal | 59 ++++-- 10 files changed, 42 insertions(+), 325 deletions(-) delete mode 100644 ouroboros-network-mock/CHANGELOG.md delete mode 100644 ouroboros-network-mock/LICENSE delete mode 100644 ouroboros-network-mock/NOTICE delete mode 100644 ouroboros-network-mock/changelog.d/scriv.ini delete mode 100644 ouroboros-network-mock/ouroboros-network-mock.cabal rename {ouroboros-network-mock/src => ouroboros-network/mock}/Ouroboros/Network/Mock/Chain.hs (100%) rename {ouroboros-network-mock/src => ouroboros-network/mock}/Ouroboros/Network/Mock/ConcreteBlock.hs (100%) rename {ouroboros-network-mock/src => ouroboros-network/mock}/Ouroboros/Network/Mock/ProducerState.hs (100%) diff --git a/cabal.project b/cabal.project index 4207373b16c..2ef5486f519 100644 --- a/cabal.project +++ b/cabal.project @@ -25,7 +25,6 @@ packages: ./cardano-ping ./network-mux ./ouroboros-network ./ouroboros-network-api - ./ouroboros-network-mock ./ouroboros-network-testing ./ntp-client ./cardano-client diff --git a/ouroboros-network-mock/CHANGELOG.md b/ouroboros-network-mock/CHANGELOG.md deleted file mode 100644 index 2fa36eed900..00000000000 --- a/ouroboros-network-mock/CHANGELOG.md +++ /dev/null @@ -1,42 +0,0 @@ -# ouroboros-network-mock changelog - - - - -## 0.1.1.2 -- 2024-08-07 - -### Breaking changes - -### Non-breaking changes - -* Make it build with ghc-9.10 - -## 0.1.1.1 -- 2024-01-22 - -### Non-breaking changes - -* ghc-9.8 support. - -## 0.1.1.0 -- 2023-11-02 - -### Non-breaking changes - -* Clarified `successorBlock`'s contract (specifying that behavior is undefined - when the provided point isn't on the provided chain) and leveraged it to - prevent a call to `error`. - -## 0.1.0.2 -- 2023-10-26 - -### Non-breaking changes - -* Fixed cabal warnings. - -## 0.1.0.1 -- 2023-04-28 - -### Non-breaking changes - -* `ghc-9.4` and `ghc-9.6` compatibility. - -## 0.1.0.0 -- 2022-11-17 - -* Initial release diff --git a/ouroboros-network-mock/LICENSE b/ouroboros-network-mock/LICENSE deleted file mode 100644 index f433b1a53f5..00000000000 --- a/ouroboros-network-mock/LICENSE +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/ouroboros-network-mock/NOTICE b/ouroboros-network-mock/NOTICE deleted file mode 100644 index 3efdc24424e..00000000000 --- a/ouroboros-network-mock/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/ouroboros-network-mock/changelog.d/scriv.ini b/ouroboros-network-mock/changelog.d/scriv.ini deleted file mode 100644 index 0a55d0ce6ee..00000000000 --- a/ouroboros-network-mock/changelog.d/scriv.ini +++ /dev/null @@ -1,15 +0,0 @@ -[scriv] -format = md -insert_marker = Changelog entries -md_header_level = 2 -version = literal: ouroboros-network-mock.cabal: version -categories = Breaking, Non-Breaking -start_marker = scriv-insert-here -end_marker = scriv-end-here -fragment_directory = changelog.d -ghrel_template = {{body}} -main_branches = main -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = CHANGELOG.${config:format} -skip_fragments = README.* -entry_title_template = {%% if version %%}{{ version }} -- {%% endif %%}{{ date.strftime('%%Y-%%m-%%d') }} diff --git a/ouroboros-network-mock/ouroboros-network-mock.cabal b/ouroboros-network-mock/ouroboros-network-mock.cabal deleted file mode 100644 index c3a7674ef5a..00000000000 --- a/ouroboros-network-mock/ouroboros-network-mock.cabal +++ /dev/null @@ -1,59 +0,0 @@ -cabal-version: 3.0 -name: ouroboros-network-mock -version: 0.1.1.2 -synopsis: Ouroboros Network Chain for testing purposes -description: Ouroboros Network Chain for testing purposes. -license: Apache-2.0 -license-files: - LICENSE - NOTICE - -copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect -author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts -maintainer: marcin.szamotulski@iohk.io -category: Network -build-type: Simple -extra-doc-files: CHANGELOG.md - -flag asserts - description: Enable assertions - manual: False - default: False - -source-repository head - type: git - location: https://github.com/intersectmbo/ouroboros-network - -library - hs-source-dirs: src - exposed-modules: - Ouroboros.Network.Mock.Chain - Ouroboros.Network.Mock.ConcreteBlock - Ouroboros.Network.Mock.ProducerState - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - build-depends: - base >=4.14 && <4.22, - bytestring, - cborg, - containers, - hashable, - nothunks, - ouroboros-network-api, - serialise, - time, - - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wunused-packages - - if flag(asserts) - ghc-options: -fno-ignore-asserts diff --git a/ouroboros-network-mock/src/Ouroboros/Network/Mock/Chain.hs b/ouroboros-network/mock/Ouroboros/Network/Mock/Chain.hs similarity index 100% rename from ouroboros-network-mock/src/Ouroboros/Network/Mock/Chain.hs rename to ouroboros-network/mock/Ouroboros/Network/Mock/Chain.hs diff --git a/ouroboros-network-mock/src/Ouroboros/Network/Mock/ConcreteBlock.hs b/ouroboros-network/mock/Ouroboros/Network/Mock/ConcreteBlock.hs similarity index 100% rename from ouroboros-network-mock/src/Ouroboros/Network/Mock/ConcreteBlock.hs rename to ouroboros-network/mock/Ouroboros/Network/Mock/ConcreteBlock.hs diff --git a/ouroboros-network-mock/src/Ouroboros/Network/Mock/ProducerState.hs b/ouroboros-network/mock/Ouroboros/Network/Mock/ProducerState.hs similarity index 100% rename from ouroboros-network-mock/src/Ouroboros/Network/Mock/ProducerState.hs rename to ouroboros-network/mock/Ouroboros/Network/Mock/ProducerState.hs diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 124decd318f..0be7b1f7644 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -715,10 +715,8 @@ library protocols-tests-lib io-sim, network, network-mux, - ouroboros-network:framework, - ouroboros-network:protocols, ouroboros-network-api, - ouroboros-network-mock, + ouroboros-network:{framework, mock, protocols}, ouroboros-network-testing, pipes, quickcheck-instances, @@ -733,7 +731,7 @@ test-suite protocols-tests type: exitcode-stdio-1.0 hs-source-dirs: protocols/tests main-is: Main.hs - -- TODO: these two tests should be moved to `ouroboros-network-mock` + -- TODO: these two tests should be moved to `ouroboros-network:mock` other-modules: Test.AnchoredFragment Test.Chain @@ -745,7 +743,7 @@ test-suite protocols-tests base >=4.14 && <4.22, ouroboros-network:protocols-tests-lib, ouroboros-network-api, - ouroboros-network-mock, + ouroboros-network:{mock, protocols-tests-lib}, ouroboros-network-testing ^>=0.8, tasty, tasty-quickcheck, @@ -779,10 +777,8 @@ test-suite protocols-cddl filepath, mtl, network, - ouroboros-network:framework, - ouroboros-network:{protocols, protocols-tests-lib}, + ouroboros-network:{mock, framework, protocols, protocols-tests-lib}, ouroboros-network-api, - ouroboros-network-mock, process-extras, quickcheck-instances, serialise, @@ -813,7 +809,6 @@ test-suite protocols-bench deepseq, network, ouroboros-network:{framework, protocols, protocols-tests-lib}, - ouroboros-network:{protocols, protocols-tests-lib}, ouroboros-network-api, tasty-bench, typed-protocols:{typed-protocols, stateful}, @@ -832,6 +827,41 @@ test-suite protocols-bench if impl(ghc >=8.6) ghc-options: -fproc-alignment=64 +library mock + visibility: public + hs-source-dirs: mock + exposed-modules: + Ouroboros.Network.Mock.Chain + Ouroboros.Network.Mock.ConcreteBlock + Ouroboros.Network.Mock.ProducerState + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + build-depends: + base >=4.14 && <4.22, + bytestring, + cborg, + containers, + hashable, + nothunks, + ouroboros-network-api, + serialise, + time, + + ghc-options: + -Wall + -Wno-unticked-promoted-constructors + -Wcompat + -Wincomplete-uni-patterns + -Wincomplete-record-updates + -Wpartial-fields + -Widentities + -Wredundant-constraints + -Wunused-packages + + if flag(asserts) + ghc-options: -fno-ignore-asserts + -- Simulation Test Library library testlib import: ghc-options-tests @@ -861,9 +891,8 @@ library testlib network, network-mux, nothunks, - ouroboros-network:{ouroboros-network, cardano-diffusion, framework, framework-tests-lib, orphan-instances, protocols, protocols-tests-lib}, + ouroboros-network:{cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, ouroboros-network, protocols, protocols-tests-lib}, ouroboros-network-api, - ouroboros-network-mock, ouroboros-network-testing ^>=0.8.3, pipes, pretty-simple, @@ -965,11 +994,8 @@ test-suite io-tests monoidal-synchronisation, network, network-mux, - ouroboros-network:cardano-diffusion, - ouroboros-network:{framework, protocols, protocols-tests-lib}, - ouroboros-network:{protocols, protocols-tests-lib}, + ouroboros-network:{cardano-diffusion, framework, mock, protocols, protocols-tests-lib}, ouroboros-network-api, - ouroboros-network-mock, ouroboros-network-testing ^>=0.8.1, serialise, tasty, @@ -1005,9 +1031,8 @@ executable demo-chain-sync io-classes:{si-timers, strict-stm}, network-mux, optparse-applicative, - ouroboros-network:{ouroboros-network, cardano-diffusion, framework, protocols}, + ouroboros-network:{ouroboros-network, cardano-diffusion, framework, mock, protocols}, ouroboros-network-api, - ouroboros-network-mock, random, serialise, typed-protocols, From 5b63b4bfe777dce9d17e1b8bab7b5e2523d3ffcb Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 16 Sep 2025 09:53:44 +0200 Subject: [PATCH 05/24] Reorganised ouroboros-network.cabal file ouroboros-network tests moved / renamed: * `ouroboros-network:testlib` -> `ouroboros-network:ouroboros-network-tests-lib` in `tests/lib` * `ouroboros-network:sim-tests` -> `ouroboros-network:ouroboros-network-sim-tests` in `tests/sim` * `ouroboros-network:io-tests` -> `ouroboros-network:ouroboros-network-io-tests` in `tests/io` --- .../Class/MonadSTM/Strict/TMergeVar.hs | 0 .../Ouroboros/Network/BlockFetch.hs | 0 .../Ouroboros/Network/BlockFetch/Client.hs | 0 .../Network/BlockFetch/ClientRegistry.hs | 0 .../Network/BlockFetch/ClientState.hs | 0 .../Ouroboros/Network/BlockFetch/Decision.hs | 0 .../Network/BlockFetch/Decision/Genesis.hs | 0 .../Network/BlockFetch/Decision/Trace.hs | 0 .../Ouroboros/Network/BlockFetch/DeltaQ.hs | 0 .../Ouroboros/Network/BlockFetch/State.hs | 0 .../{src => lib}/Ouroboros/Network/DeltaQ.hs | 0 .../Ouroboros/Network/Diffusion.hs | 0 .../Network/Diffusion/Configuration.hs | 0 .../Ouroboros/Network/Diffusion/Policies.hs | 0 .../Ouroboros/Network/Diffusion/Topology.hs | 0 .../Ouroboros/Network/Diffusion/Types.hs | 0 .../Ouroboros/Network/Diffusion/Utils.hs | 0 .../Ouroboros/Network/ExitPolicy.hs | 0 .../Ouroboros/Network/KeepAlive.hs | 0 .../Ouroboros/Network/PeerSelection.hs | 0 .../Ouroboros/Network/PeerSelection/Churn.hs | 0 .../Network/PeerSelection/Governor.hs | 0 .../PeerSelection/Governor/ActivePeers.hs | 0 .../PeerSelection/Governor/BigLedgerPeers.hs | 0 .../Governor/EstablishedPeers.hs | 0 .../PeerSelection/Governor/KnownPeers.hs | 0 .../Network/PeerSelection/Governor/Monitor.hs | 0 .../PeerSelection/Governor/RootPeers.hs | 0 .../Network/PeerSelection/Governor/Types.hs | 0 .../Network/PeerSelection/LedgerPeers.hs | 0 .../Network/PeerSelection/PeerMetric.hs | 0 .../PeerSelection/PeerSelectionActions.hs | 0 .../Network/PeerSelection/PeerStateActions.hs | 0 .../Network/PeerSelection/PublicRootPeers.hs | 0 .../Network/PeerSelection/RootPeersDNS.hs | 0 .../PeerSelection/RootPeersDNS/DNSActions.hs | 0 .../RootPeersDNS/DNSSemaphore.hs | 0 .../PeerSelection/RootPeersDNS/LedgerPeers.hs | 0 .../RootPeersDNS/LocalRootPeers.hs | 0 .../RootPeersDNS/PublicRootPeers.hs | 0 .../PeerSelection/State/EstablishedPeers.hs | 0 .../Network/PeerSelection/State/KnownPeers.hs | 0 .../PeerSelection/State/LocalRootPeers.hs | 0 .../Ouroboros/Network/PeerSelection/Types.hs | 0 .../Ouroboros/Network/PeerSharing.hs | 0 .../Ouroboros/Network/TxSubmission/Inbound.hs | 0 .../Network/TxSubmission/Inbound/V1.hs | 0 .../Network/TxSubmission/Inbound/V2.hs | 0 .../TxSubmission/Inbound/V2/Decision.hs | 0 .../Network/TxSubmission/Inbound/V2/Policy.hs | 0 .../TxSubmission/Inbound/V2/Registry.hs | 0 .../Network/TxSubmission/Inbound/V2/State.hs | 0 .../Network/TxSubmission/Inbound/V2/Types.hs | 0 .../Network/TxSubmission/Mempool/Reader.hs | 0 .../Network/TxSubmission/Mempool/Simple.hs | 0 .../Network/TxSubmission/Outbound.hs | 0 ouroboros-network/ouroboros-network.cabal | 132 +++--------------- .../{io-tests => tests/io}/Main.hs | 0 .../io}/Test/Ouroboros/Network/Pipe.hs | 0 .../io}/Test/Ouroboros/Network/Socket.hs | 0 .../Ouroboros/Network/BlockFetch/Examples.hs | 0 .../lib}/Ouroboros/Network/MockNode.hs | 0 .../Cardano/Network/NodeToClient/Version.hs | 0 .../Cardano/Network/NodeToNode/Version.hs | 0 .../Cardano/Network/OrphanInstances/Tests.hs | 0 .../lib}/Test/Cardano/Network/Version.hs | 0 .../lib}/Test/Ouroboros/Network/BlockFetch.hs | 0 .../Test/Ouroboros/Network/Diffusion/Node.hs | 0 .../Network/Diffusion/Node/ChainDB.hs | 0 .../Network/Diffusion/Node/Kernel.hs | 0 .../Network/Diffusion/Node/MiniProtocols.hs | 0 .../Ouroboros/Network/Diffusion/Policies.hs | 0 .../Network/Diffusion/Testnet/Cardano.hs | 0 .../Diffusion/Testnet/Cardano/Simulation.hs | 0 .../lib}/Test/Ouroboros/Network/KeepAlive.hs | 0 .../Test/Ouroboros/Network/LedgerPeers.hs | 0 .../lib}/Test/Ouroboros/Network/MockNode.hs | 0 .../lib}/Test/Ouroboros/Network/Mux.hs | 0 .../Ouroboros/Network/NodeToClient/Version.hs | 0 .../Ouroboros/Network/NodeToNode/Version.hs | 0 .../Network/OrphanInstances/Tests.hs | 0 .../lib}/Test/Ouroboros/Network/Orphans.hs | 0 .../Test/Ouroboros/Network/PeerSelection.hs | 0 .../PeerSelection/Cardano/Instances.hs | 0 .../PeerSelection/Cardano/LocalRootPeers.hs | 0 .../PeerSelection/Cardano/MockEnvironment.hs | 0 .../PeerSelection/Cardano/PublicRootPeers.hs | 0 .../Ouroboros/Network/PeerSelection/Gource.hs | 0 .../Network/PeerSelection/Instances.hs | 0 .../Network/PeerSelection/KnownPeers.hs | 0 .../Network/PeerSelection/LocalRootPeers.hs | 0 .../Network/PeerSelection/PeerGraph.hs | 0 .../Network/PeerSelection/PeerMetric.hs | 0 .../Network/PeerSelection/RootPeersDNS.hs | 0 .../Ouroboros/Network/PeerSelection/Utils.hs | 0 .../Test/Ouroboros/Network/TxSubmission.hs | 0 .../Ouroboros/Network/TxSubmission/AppV1.hs | 0 .../Ouroboros/Network/TxSubmission/AppV2.hs | 0 .../Ouroboros/Network/TxSubmission/TxLogic.hs | 0 .../Network/TxSubmission/TxSubmissionV2.hs | 0 .../Ouroboros/Network/TxSubmission/Types.hs | 0 .../lib}/Test/Ouroboros/Network/Version.hs | 0 .../{sim-tests => tests/sim}/Main.hs | 0 103 files changed, 22 insertions(+), 110 deletions(-) rename ouroboros-network/{src => lib}/Control/Concurrent/Class/MonadSTM/Strict/TMergeVar.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch/Client.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch/ClientRegistry.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch/ClientState.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch/Decision.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch/Decision/Genesis.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch/Decision/Trace.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch/DeltaQ.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/BlockFetch/State.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/DeltaQ.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/Diffusion.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/Diffusion/Configuration.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/Diffusion/Policies.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/Diffusion/Topology.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/Diffusion/Types.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/Diffusion/Utils.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/ExitPolicy.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/KeepAlive.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Churn.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Governor.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Governor/Monitor.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Governor/Types.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/LedgerPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/PeerMetric.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/PeerStateActions.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/PublicRootPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/RootPeersDNS.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSActions.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSSemaphore.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/RootPeersDNS/LedgerPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/RootPeersDNS/LocalRootPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/RootPeersDNS/PublicRootPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/State/EstablishedPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/State/KnownPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSelection/Types.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/PeerSharing.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Inbound.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Inbound/V1.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Inbound/V2.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Inbound/V2/Decision.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Inbound/V2/Policy.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Inbound/V2/State.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Inbound/V2/Types.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Mempool/Reader.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Mempool/Simple.hs (100%) rename ouroboros-network/{src => lib}/Ouroboros/Network/TxSubmission/Outbound.hs (100%) rename ouroboros-network/{io-tests => tests/io}/Main.hs (100%) rename ouroboros-network/{io-tests => tests/io}/Test/Ouroboros/Network/Pipe.hs (100%) rename ouroboros-network/{io-tests => tests/io}/Test/Ouroboros/Network/Socket.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Ouroboros/Network/BlockFetch/Examples.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Ouroboros/Network/MockNode.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Cardano/Network/NodeToClient/Version.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Cardano/Network/NodeToNode/Version.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Cardano/Network/OrphanInstances/Tests.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Cardano/Network/Version.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/BlockFetch.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Diffusion/Node.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Diffusion/Node/ChainDB.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Diffusion/Policies.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/KeepAlive.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/LedgerPeers.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/MockNode.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Mux.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/NodeToClient/Version.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/NodeToNode/Version.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/OrphanInstances/Tests.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Orphans.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/Cardano/Instances.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/Cardano/LocalRootPeers.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/Cardano/PublicRootPeers.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/Gource.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/Instances.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/KnownPeers.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/LocalRootPeers.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/PeerGraph.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/PeerMetric.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/PeerSelection/Utils.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/TxSubmission.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/TxSubmission/AppV1.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/TxSubmission/AppV2.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/TxSubmission/TxLogic.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/TxSubmission/TxSubmissionV2.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/TxSubmission/Types.hs (100%) rename ouroboros-network/{testlib => tests/lib}/Test/Ouroboros/Network/Version.hs (100%) rename ouroboros-network/{sim-tests => tests/sim}/Main.hs (100%) diff --git a/ouroboros-network/src/Control/Concurrent/Class/MonadSTM/Strict/TMergeVar.hs b/ouroboros-network/lib/Control/Concurrent/Class/MonadSTM/Strict/TMergeVar.hs similarity index 100% rename from ouroboros-network/src/Control/Concurrent/Class/MonadSTM/Strict/TMergeVar.hs rename to ouroboros-network/lib/Control/Concurrent/Class/MonadSTM/Strict/TMergeVar.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch/Client.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch/Client.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch/Client.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch/Client.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch/ClientRegistry.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch/ClientRegistry.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch/ClientRegistry.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch/ClientRegistry.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch/ClientState.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch/ClientState.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch/ClientState.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch/ClientState.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch/Decision.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch/Decision.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch/Decision.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch/Decision.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch/Decision/Genesis.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch/Decision/Genesis.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch/Decision/Genesis.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch/Decision/Genesis.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch/Decision/Trace.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch/Decision/Trace.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch/Decision/Trace.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch/Decision/Trace.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch/DeltaQ.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch/DeltaQ.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch/DeltaQ.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch/DeltaQ.hs diff --git a/ouroboros-network/src/Ouroboros/Network/BlockFetch/State.hs b/ouroboros-network/lib/Ouroboros/Network/BlockFetch/State.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/BlockFetch/State.hs rename to ouroboros-network/lib/Ouroboros/Network/BlockFetch/State.hs diff --git a/ouroboros-network/src/Ouroboros/Network/DeltaQ.hs b/ouroboros-network/lib/Ouroboros/Network/DeltaQ.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/DeltaQ.hs rename to ouroboros-network/lib/Ouroboros/Network/DeltaQ.hs diff --git a/ouroboros-network/src/Ouroboros/Network/Diffusion.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/Diffusion.hs rename to ouroboros-network/lib/Ouroboros/Network/Diffusion.hs diff --git a/ouroboros-network/src/Ouroboros/Network/Diffusion/Configuration.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/Diffusion/Configuration.hs rename to ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs diff --git a/ouroboros-network/src/Ouroboros/Network/Diffusion/Policies.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Policies.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/Diffusion/Policies.hs rename to ouroboros-network/lib/Ouroboros/Network/Diffusion/Policies.hs diff --git a/ouroboros-network/src/Ouroboros/Network/Diffusion/Topology.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/Diffusion/Topology.hs rename to ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs diff --git a/ouroboros-network/src/Ouroboros/Network/Diffusion/Types.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/Diffusion/Types.hs rename to ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs diff --git a/ouroboros-network/src/Ouroboros/Network/Diffusion/Utils.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Utils.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/Diffusion/Utils.hs rename to ouroboros-network/lib/Ouroboros/Network/Diffusion/Utils.hs diff --git a/ouroboros-network/src/Ouroboros/Network/ExitPolicy.hs b/ouroboros-network/lib/Ouroboros/Network/ExitPolicy.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/ExitPolicy.hs rename to ouroboros-network/lib/Ouroboros/Network/ExitPolicy.hs diff --git a/ouroboros-network/src/Ouroboros/Network/KeepAlive.hs b/ouroboros-network/lib/Ouroboros/Network/KeepAlive.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/KeepAlive.hs rename to ouroboros-network/lib/Ouroboros/Network/KeepAlive.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Churn.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Churn.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Monitor.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Monitor.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Types.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Types.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/LedgerPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/LedgerPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/LedgerPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/LedgerPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerMetric.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerMetric.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerMetric.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerMetric.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerStateActions.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerStateActions.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerStateActions.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerStateActions.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/PublicRootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PublicRootPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/PublicRootPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/PublicRootPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSActions.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSActions.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSActions.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSActions.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSSemaphore.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSSemaphore.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSSemaphore.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/DNSSemaphore.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/LedgerPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/LedgerPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/LedgerPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/LedgerPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/LocalRootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/LocalRootPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/LocalRootPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/LocalRootPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/PublicRootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/PublicRootPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/RootPeersDNS/PublicRootPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/RootPeersDNS/PublicRootPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/State/EstablishedPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/EstablishedPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/State/EstablishedPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/EstablishedPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/State/KnownPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/KnownPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/State/KnownPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/KnownPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Types.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Types.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSelection/Types.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSelection/Types.hs diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSharing.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSharing.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/PeerSharing.hs rename to ouroboros-network/lib/Ouroboros/Network/PeerSharing.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V1.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V1.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/Decision.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Decision.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/Decision.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Decision.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/Policy.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Policy.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/Policy.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Policy.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/State.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/State.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/State.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/State.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/Types.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Types.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/V2/Types.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Types.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Mempool/Reader.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Mempool/Reader.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Mempool/Reader.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Mempool/Reader.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Mempool/Simple.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Mempool/Simple.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Mempool/Simple.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Mempool/Simple.hs diff --git a/ouroboros-network/src/Ouroboros/Network/TxSubmission/Outbound.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Outbound.hs similarity index 100% rename from ouroboros-network/src/Ouroboros/Network/TxSubmission/Outbound.hs rename to ouroboros-network/lib/Ouroboros/Network/TxSubmission/Outbound.hs diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 0be7b1f7644..f13a69170b6 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -37,6 +37,8 @@ source-repository head location: https://github.com/intersectmbo/ouroboros-network common ghc-options + default-language: Haskell2010 + default-extensions: ImportQualifiedPost ghc-options: -Wall -Wno-unticked-promoted-constructors @@ -48,6 +50,9 @@ common ghc-options -Wredundant-constraints -Wunused-packages + if flag(asserts) + ghc-options: -fno-ignore-asserts + -- in tests librararies redundant constraints are sometimes useful (e.g. -- by default truned off debug tracing might require extra constraints like -- `Show` or `MonadSay`). @@ -57,7 +62,7 @@ common ghc-options-tests library import: ghc-options - hs-source-dirs: src + hs-source-dirs: lib -- At this experiment/prototype stage everything is exposed. -- This has to be tidied up once the design becomes clear. exposed-modules: @@ -124,8 +129,6 @@ library Ouroboros.Network.AnchoredSeq, Ouroboros.Network.Magic, - default-language: Haskell2010 - default-extensions: ImportQualifiedPost other-extensions: BangPatterns DataKinds @@ -182,9 +185,6 @@ library build-depends: directory - if flag(asserts) - ghc-options: -fno-ignore-asserts - library framework import: ghc-options visibility: public @@ -257,8 +257,6 @@ library framework if os(windows) build-depends: Win32 >=2.5.4.1 && <3.0 hs-source-dirs: framework - default-language: Haskell2010 - default-extensions: ImportQualifiedPost library framework-tests-lib import: ghc-options @@ -272,7 +270,6 @@ library framework-tests-lib Test.Ouroboros.Network.Orphans Test.Ouroboros.Network.RawBearer.Utils - other-modules: build-depends: QuickCheck >=2.16, base >=4.14 && <4.22, @@ -291,9 +288,6 @@ library framework-tests-lib serialise, typed-protocols:{typed-protocols, examples}, - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - test-suite framework-sim-tests import: ghc-options type: exitcode-stdio-1.0 @@ -332,8 +326,6 @@ test-suite framework-sim-tests typed-protocols:{typed-protocols, cborg, examples}, with-utf8, - default-language: Haskell2010 - default-extensions: ImportQualifiedPost ghc-options: -rtsopts -threaded @@ -374,8 +366,6 @@ test-suite framework-io-tests if os(windows) build-depends: Win32-network <0.3 - default-language: Haskell2010 - default-extensions: ImportQualifiedPost ghc-options: -rtsopts -threaded @@ -388,10 +378,7 @@ library orphan-instances Cardano.Network.OrphanInstances Ouroboros.Network.OrphanInstances - other-modules: reexported-modules: - default-language: Haskell2010 - default-extensions: ImportQualifiedPost other-extensions: BangPatterns DataKinds @@ -429,10 +416,8 @@ library orphan-instances text, typed-protocols, - if flag(asserts) - ghc-options: -fno-ignore-asserts - executable demo-ping-pong + import: ghc-options hs-source-dirs: demo main-is: ping-pong.hs build-depends: @@ -446,21 +431,8 @@ executable demo-ping-pong ouroboros-network-api, typed-protocols:examples, - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -Wall - -threaded - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages - executable demo-connection-manager + import: ghc-options hs-source-dirs: demo main-is: connection-manager.hs build-depends: @@ -477,20 +449,6 @@ executable demo-connection-manager random, typed-protocols:{typed-protocols, examples}, - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -Wall - -threaded - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages - library cardano-diffusion import: ghc-options visibility: public @@ -514,8 +472,6 @@ library cardano-diffusion Cardano.Network.PeerSelection.PeerSelectionActions Cardano.Network.PeerSelection.PublicRootPeers - other-modules: - reexported-modules: default-language: Haskell2010 default-extensions: ImportQualifiedPost other-extensions: @@ -561,9 +517,6 @@ library cardano-diffusion build-depends: unix - if flag(asserts) - ghc-options: -fno-ignore-asserts - library protocols import: ghc-options visibility: public @@ -607,8 +560,6 @@ library protocols Ouroboros.Network.Protocol.TxSubmission2.Server Ouroboros.Network.Protocol.TxSubmission2.Type - default-language: Haskell2010 - default-extensions: ImportQualifiedPost other-extensions: BangPatterns DataKinds @@ -650,15 +601,10 @@ library protocols text, typed-protocols:{typed-protocols, cborg, stateful, stateful-cborg} ^>=1.1, - if flag(asserts) - ghc-options: -fno-ignore-asserts - library protocols-tests-lib import: ghc-options visibility: public hs-source-dirs: protocols/tests-lib - default-language: Haskell2010 - default-extensions: ImportQualifiedPost exposed-modules: Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL Ouroboros.Network.Protocol.BlockFetch.Direct @@ -715,8 +661,8 @@ library protocols-tests-lib io-sim, network, network-mux, - ouroboros-network-api, ouroboros-network:{framework, mock, protocols}, + ouroboros-network-api, ouroboros-network-testing, pipes, quickcheck-instances, @@ -736,14 +682,12 @@ test-suite protocols-tests Test.AnchoredFragment Test.Chain - default-language: Haskell2010 - default-extensions: ImportQualifiedPost build-depends: QuickCheck ^>=2.16, base >=4.14 && <4.22, + ouroboros-network:{mock, protocols-tests-lib}, ouroboros-network:protocols-tests-lib, ouroboros-network-api, - ouroboros-network:{mock, protocols-tests-lib}, ouroboros-network-testing ^>=0.8, tasty, tasty-quickcheck, @@ -765,8 +709,6 @@ test-suite protocols-cddl else buildable: False - default-language: Haskell2010 - default-extensions: ImportQualifiedPost build-depends: QuickCheck, base >=4.14 && <4.22, @@ -777,7 +719,7 @@ test-suite protocols-cddl filepath, mtl, network, - ouroboros-network:{mock, framework, protocols, protocols-tests-lib}, + ouroboros-network:{framework, mock, protocols, protocols-tests-lib}, ouroboros-network-api, process-extras, quickcheck-instances, @@ -796,11 +738,11 @@ test-suite protocols-cddl -with-rtsopts=-M400m test-suite protocols-bench + import: ghc-options-tests type: exitcode-stdio-1.0 default-extensions: ImportQualifiedPost hs-source-dirs: protocols/bench main-is: Main.hs - default-language: Haskell2010 build-depends: base >=4.14 && <4.22, bytestring, @@ -814,10 +756,6 @@ test-suite protocols-bench typed-protocols:{typed-protocols, stateful}, ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wunused-packages -rtsopts -with-rtsopts=-A32m -with-rtsopts=-T @@ -828,6 +766,7 @@ test-suite protocols-bench ghc-options: -fproc-alignment=64 library mock + import: ghc-options visibility: public hs-source-dirs: mock exposed-modules: @@ -835,8 +774,6 @@ library mock Ouroboros.Network.Mock.ConcreteBlock Ouroboros.Network.Mock.ProducerState - default-language: Haskell2010 - default-extensions: ImportQualifiedPost build-depends: base >=4.14 && <4.22, bytestring, @@ -848,27 +785,11 @@ library mock serialise, time, - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wunused-packages - - if flag(asserts) - ghc-options: -fno-ignore-asserts - -- Simulation Test Library -library testlib +library ouroboros-network-tests-lib import: ghc-options-tests - default-language: Haskell2010 - default-extensions: ImportQualifiedPost visibility: public - hs-source-dirs: testlib + hs-source-dirs: tests/lib build-depends: QuickCheck >=2.16, aeson, @@ -891,7 +812,7 @@ library testlib network, network-mux, nothunks, - ouroboros-network:{cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, ouroboros-network, protocols, protocols-tests-lib}, + ouroboros-network:{ouroboros-network, cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, protocols, protocols-tests-lib}, ouroboros-network-api, ouroboros-network-testing ^>=0.8.3, pipes, @@ -949,16 +870,14 @@ library testlib -- Simulation tests, and IO tests which don't require native system calls. -- (i.e. they don't require system call API provided by `Win32-network` or -- `network` dependency). test-suite sim-tests -test-suite sim-tests +test-suite ouroboros-network-sim-tests import: ghc-options-tests - default-language: Haskell2010 - default-extensions: ImportQualifiedPost type: exitcode-stdio-1.0 - hs-source-dirs: sim-tests + hs-source-dirs: tests/sim main-is: Main.hs build-depends: base >=4.14 && <4.22, - ouroboros-network:{protocols, protocols-tests-lib, testlib}, + ouroboros-network:{ouroboros-network-tests-lib, protocols-tests-lib}, tasty, with-utf8, @@ -974,17 +893,15 @@ test-suite sim-tests -- library. These tests are compiled natively & run on all supported -- platforms: x86_64-w64-mingw32 (Windows), x86_64-linux, x86-64-darwin and -- aarch64-darwin. -test-suite io-tests +test-suite ouroboros-network-io-tests import: ghc-options-tests type: exitcode-stdio-1.0 - hs-source-dirs: io-tests + hs-source-dirs: tests/io main-is: Main.hs other-modules: Test.Ouroboros.Network.Pipe Test.Ouroboros.Network.Socket - default-language: Haskell2010 - default-extensions: ImportQualifiedPost build-depends: QuickCheck >=2.16, base >=4.14 && <4.22, @@ -1037,24 +954,19 @@ executable demo-chain-sync serialise, typed-protocols, - default-language: Haskell2010 - default-extensions: ImportQualifiedPost ghc-options: - -Wall -threaded -rtsopts benchmark sim-benchmarks import: ghc-options-tests - default-language: Haskell2010 - default-extensions: ImportQualifiedPost type: exitcode-stdio-1.0 hs-source-dirs: bench main-is: Main.hs build-depends: base, deepseq, - ouroboros-network:{ouroboros-network, testlib}, + ouroboros-network:{ouroboros-network, ouroboros-network-tests-lib}, splitmix, tasty-bench >=0.3.5, diff --git a/ouroboros-network/io-tests/Main.hs b/ouroboros-network/tests/io/Main.hs similarity index 100% rename from ouroboros-network/io-tests/Main.hs rename to ouroboros-network/tests/io/Main.hs diff --git a/ouroboros-network/io-tests/Test/Ouroboros/Network/Pipe.hs b/ouroboros-network/tests/io/Test/Ouroboros/Network/Pipe.hs similarity index 100% rename from ouroboros-network/io-tests/Test/Ouroboros/Network/Pipe.hs rename to ouroboros-network/tests/io/Test/Ouroboros/Network/Pipe.hs diff --git a/ouroboros-network/io-tests/Test/Ouroboros/Network/Socket.hs b/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs similarity index 100% rename from ouroboros-network/io-tests/Test/Ouroboros/Network/Socket.hs rename to ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs diff --git a/ouroboros-network/testlib/Ouroboros/Network/BlockFetch/Examples.hs b/ouroboros-network/tests/lib/Ouroboros/Network/BlockFetch/Examples.hs similarity index 100% rename from ouroboros-network/testlib/Ouroboros/Network/BlockFetch/Examples.hs rename to ouroboros-network/tests/lib/Ouroboros/Network/BlockFetch/Examples.hs diff --git a/ouroboros-network/testlib/Ouroboros/Network/MockNode.hs b/ouroboros-network/tests/lib/Ouroboros/Network/MockNode.hs similarity index 100% rename from ouroboros-network/testlib/Ouroboros/Network/MockNode.hs rename to ouroboros-network/tests/lib/Ouroboros/Network/MockNode.hs diff --git a/ouroboros-network/testlib/Test/Cardano/Network/NodeToClient/Version.hs b/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToClient/Version.hs similarity index 100% rename from ouroboros-network/testlib/Test/Cardano/Network/NodeToClient/Version.hs rename to ouroboros-network/tests/lib/Test/Cardano/Network/NodeToClient/Version.hs diff --git a/ouroboros-network/testlib/Test/Cardano/Network/NodeToNode/Version.hs b/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToNode/Version.hs similarity index 100% rename from ouroboros-network/testlib/Test/Cardano/Network/NodeToNode/Version.hs rename to ouroboros-network/tests/lib/Test/Cardano/Network/NodeToNode/Version.hs diff --git a/ouroboros-network/testlib/Test/Cardano/Network/OrphanInstances/Tests.hs b/ouroboros-network/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs similarity index 100% rename from ouroboros-network/testlib/Test/Cardano/Network/OrphanInstances/Tests.hs rename to ouroboros-network/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs diff --git a/ouroboros-network/testlib/Test/Cardano/Network/Version.hs b/ouroboros-network/tests/lib/Test/Cardano/Network/Version.hs similarity index 100% rename from ouroboros-network/testlib/Test/Cardano/Network/Version.hs rename to ouroboros-network/tests/lib/Test/Cardano/Network/Version.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/BlockFetch.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/BlockFetch.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Node.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Node.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Node/ChainDB.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/ChainDB.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Node/ChainDB.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/ChainDB.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Policies.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Policies.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Policies.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Policies.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/KeepAlive.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/KeepAlive.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/KeepAlive.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/KeepAlive.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/LedgerPeers.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/LedgerPeers.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/LedgerPeers.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/LedgerPeers.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/MockNode.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/MockNode.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/MockNode.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/MockNode.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Mux.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Mux.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Mux.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Mux.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/NodeToClient/Version.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToClient/Version.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/NodeToClient/Version.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToClient/Version.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/NodeToNode/Version.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToNode/Version.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/NodeToNode/Version.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToNode/Version.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/OrphanInstances/Tests.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/OrphanInstances/Tests.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/OrphanInstances/Tests.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/OrphanInstances/Tests.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Orphans.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Orphans.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Orphans.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Orphans.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Cardano/Instances.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/Instances.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Cardano/Instances.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/Instances.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Cardano/LocalRootPeers.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/LocalRootPeers.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Cardano/LocalRootPeers.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/LocalRootPeers.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Cardano/PublicRootPeers.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/PublicRootPeers.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Cardano/PublicRootPeers.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/PublicRootPeers.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Gource.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Gource.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Gource.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Gource.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Instances.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Instances.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/KnownPeers.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/KnownPeers.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/KnownPeers.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/KnownPeers.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/LocalRootPeers.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/LocalRootPeers.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/LocalRootPeers.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/LocalRootPeers.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/PeerGraph.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/PeerGraph.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/PeerGraph.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/PeerGraph.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/PeerMetric.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/PeerMetric.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/PeerMetric.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/PeerMetric.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Utils.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Utils.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/PeerSelection/Utils.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Utils.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/AppV1.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV1.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/AppV1.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV1.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/AppV2.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV2.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/AppV2.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV2.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/TxLogic.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/TxLogic.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/TxLogic.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/TxLogic.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/TxSubmissionV2.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/TxSubmissionV2.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/TxSubmissionV2.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/TxSubmissionV2.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/Types.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/Types.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/TxSubmission/Types.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/Types.hs diff --git a/ouroboros-network/testlib/Test/Ouroboros/Network/Version.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Version.hs similarity index 100% rename from ouroboros-network/testlib/Test/Ouroboros/Network/Version.hs rename to ouroboros-network/tests/lib/Test/Ouroboros/Network/Version.hs diff --git a/ouroboros-network/sim-tests/Main.hs b/ouroboros-network/tests/sim/Main.hs similarity index 100% rename from ouroboros-network/sim-tests/Main.hs rename to ouroboros-network/tests/sim/Main.hs From c35daadeb82116351540c2aeabb8b1f1613d9d1c Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 16 Sep 2025 10:03:17 +0200 Subject: [PATCH 06/24] Moved ouroboros-network-testing to ouroboros-network * `ouroboros-network-testing` -> `ouroboros-network:tests-lib` in `tests-lib/lib` * `ouroboros-network-testing:test` -> `ouroboros-network:tests-lib` in `tests-lib/tests` --- cabal.project | 1 - dmq-node/dmq-node.cabal | 4 +- ouroboros-network-testing/CHANGELOG.md | 151 --------------- ouroboros-network-testing/LICENSE | 177 ------------------ ouroboros-network-testing/NOTICE | 14 -- .../changelog.d/scriv.ini | 15 -- .../ouroboros-network-testing.cabal | 121 ------------ ouroboros-network/ouroboros-network.cabal | 112 +++++++++-- .../Ouroboros/Network/Data/AbsBearerInfo.hs | 0 .../Test/Ouroboros/Network/Data/Script.hs | 0 .../Test/Ouroboros/Network/Data/Signal.hs | 0 .../lib}/Test/Ouroboros/Network/QuickCheck.hs | 0 .../lib}/Test/Ouroboros/Network/Serialise.hs | 0 .../lib}/Test/Ouroboros/Network/Utils.hs | 0 .../tests-lib/tests}/Main.hs | 0 .../Network/Data/AbsBearerInfo/Test.hs | 0 16 files changed, 99 insertions(+), 496 deletions(-) delete mode 100644 ouroboros-network-testing/CHANGELOG.md delete mode 100644 ouroboros-network-testing/LICENSE delete mode 100644 ouroboros-network-testing/NOTICE delete mode 100644 ouroboros-network-testing/changelog.d/scriv.ini delete mode 100644 ouroboros-network-testing/ouroboros-network-testing.cabal rename {ouroboros-network-testing/src => ouroboros-network/tests-lib/lib}/Test/Ouroboros/Network/Data/AbsBearerInfo.hs (100%) rename {ouroboros-network-testing/src => ouroboros-network/tests-lib/lib}/Test/Ouroboros/Network/Data/Script.hs (100%) rename {ouroboros-network-testing/src => ouroboros-network/tests-lib/lib}/Test/Ouroboros/Network/Data/Signal.hs (100%) rename {ouroboros-network-testing/src => ouroboros-network/tests-lib/lib}/Test/Ouroboros/Network/QuickCheck.hs (100%) rename {ouroboros-network-testing/src => ouroboros-network/tests-lib/lib}/Test/Ouroboros/Network/Serialise.hs (100%) rename {ouroboros-network-testing/src => ouroboros-network/tests-lib/lib}/Test/Ouroboros/Network/Utils.hs (100%) rename {ouroboros-network-testing/test => ouroboros-network/tests-lib/tests}/Main.hs (100%) rename {ouroboros-network-testing/test => ouroboros-network/tests-lib/tests}/Test/Ouroboros/Network/Data/AbsBearerInfo/Test.hs (100%) diff --git a/cabal.project b/cabal.project index 2ef5486f519..6cd85a505c0 100644 --- a/cabal.project +++ b/cabal.project @@ -25,7 +25,6 @@ packages: ./cardano-ping ./network-mux ./ouroboros-network ./ouroboros-network-api - ./ouroboros-network-testing ./ntp-client ./cardano-client ./dmq-node diff --git a/dmq-node/dmq-node.cabal b/dmq-node/dmq-node.cabal index 16aea2e0227..bb9601b8c35 100644 --- a/dmq-node/dmq-node.cabal +++ b/dmq-node/dmq-node.cabal @@ -172,10 +172,8 @@ test-suite dmq-test io-classes, io-sim, kes-agent-crypto, - ouroboros-network:{framework, protocols, protocols-tests-lib}, - ouroboros-network:{protocols, protocols-tests-lib}, + ouroboros-network:{framework, protocols, protocols-tests-lib, tests-lib}, ouroboros-network-api, - ouroboros-network-testing, quickcheck-instances, serialise, tasty, diff --git a/ouroboros-network-testing/CHANGELOG.md b/ouroboros-network-testing/CHANGELOG.md deleted file mode 100644 index e8b62d55071..00000000000 --- a/ouroboros-network-testing/CHANGELOG.md +++ /dev/null @@ -1,151 +0,0 @@ -# ouroboros-network-testing changelog - - - - -## 0.8.3.0 -- 10.09.2025 - -### Breaking changes - -### Non-breaking changes -* `renderRanges`: print a range using math notation for open/closed intervals. -* Pretty print `WithName` using `Show` instance. -* Pretty print `WithTime` using `Show` instance. -* Added `DistinctList` and `DistinctNEList` quickcheck modifiers. - -## 0.8.2.0 -- 28.06.2025 - -### Non-breaking changes - -* Support `io-classes-1.8`. -* Improved `Arbitrary` instances for `Delay` and `SmallDelay`. -* Improved `Show` instances for `WithName` and `WithTime`. - -## 0.8.1.0 -- 2025-02-25 - -### Non-breaking changes - -* Added `Test.Ouroboros.Network.Data.Signal.keydLinger'`. - -## 0.8.0.0 -- 2025-01-02 - -### Breaking changes - -* Renamed modules from `Ouroboros.Network.Testing.*` to `Test.Ouroboros.Network.*` -* Added `IOError` field to `ErrorInterval :: AbsAttenuation` constructor. - -### Non-Breaking changes - -* Added `AbsIOError` quickcheck generator for `IOError`s. - -## 0.7.0.0 -- 2024-08-07 - -### Breaking changes - -* Improvements and bug fixes to Signal API - -### Non-Breaking changes - -* Make it build with ghc-9.10 - -## 0.6.2.0 -- 2024-06-07 - -### Breaking changes - -### Non-Breaking changes - -- Bump io-sim and io-classes -* Added `isSubsetProperty` and `disjoinSetsProperty` to `Ouroboros.Network.Testing.Utils`. - -## 0.6.1.0 -- 2024-05-07 - -### Breaking changes - -### Non-Breaking changes - -## 0.6.0.0 -- 2024-02-21 - -### Breaking changes - -* Fixed Script strict API functions. Now functions with an apostrophe `'` are - properly strict variants of the non-apostrophe functions. - -### Non-breaking changes - -## 0.5.0.0 -- 2024-01-22 - -### Breaking changes - -* Adds `eventually` and `eventsToListWithId` functions to Signal API - -### Non-breaking changes - -* ghc-9.8 support - -## 0.4.1.0 -- 2023-12-14 - -### Non-breaking changes - -* Use `io-sim-1.3.1.0` - -## 0.4.0.1 -- 2023-11-16 - -### Non-breaking changes - -* Use `io-sim-1.3.0.0`. - -## 0.4.0.0 -- 2023-10-26 - -### Breaking changes - -- Changed `prop_shrink_valid` to use `ShrinkCarefully` -- Changed `prop_shrink_nonempty` to use `ShrinkCarefully` (formerlly - `prop_shrinkCarefully` was defined in `ouroboros-network:sim-test`) - -### Non-breaking changes - -- Added 'keyedTimeoutTruncated' to Signal API - -## 0.3.1.0 -- 2023-08-09 - -### Breaking changes - -### Non breaking changes - -* type signature of `prop_shrink_valid` is more admissible -* added `singletonTimedScript` -* added `Ouroboros.Network.Testing.Data.Script.shrinkScriptWith` - -## 0.3.0.0 - -### Breaking changes - -* `io-classes-1.1` support. - -### Non-breaking changes - -* `ghc-9.4` and `ghc-9.6` compatibility. - -## 0.2.0.1 - -* Release a version compatible with `ghc-9.2` - -## 0.2.0.0 - -/only the most recent changes/ - -### Breaking changes - -* `keydTimeout` does not ignore tail (PR #4086) -* Added `Delay` constructor to `ScriptDelay` - -### Non-breaking changes - -* Added `Ouroboros.Network.Testing.Data.Signal.fromEventsWith` (PR #4086) -* Added `NonFailingAbsBearerInfo` with its arbitrary instances and - `toNonfailingAbsBearerInfo` (PR #3862). -* Added `stepScriptOrFinish` and `stepScriptOrFinishSTM` - -## 0.1.0.0 -- 2019-03-07 - -* Initial version diff --git a/ouroboros-network-testing/LICENSE b/ouroboros-network-testing/LICENSE deleted file mode 100644 index f433b1a53f5..00000000000 --- a/ouroboros-network-testing/LICENSE +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/ouroboros-network-testing/NOTICE b/ouroboros-network-testing/NOTICE deleted file mode 100644 index 3efdc24424e..00000000000 --- a/ouroboros-network-testing/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/ouroboros-network-testing/changelog.d/scriv.ini b/ouroboros-network-testing/changelog.d/scriv.ini deleted file mode 100644 index dbbb40106ec..00000000000 --- a/ouroboros-network-testing/changelog.d/scriv.ini +++ /dev/null @@ -1,15 +0,0 @@ -[scriv] -format = md -insert_marker = Changelog entries -md_header_level = 2 -version = literal: ouroboros-network-testing.cabal: version -categories = Breaking, Non-Breaking -start_marker = scriv-insert-here -end_marker = scriv-end-here -fragment_directory = changelog.d -ghrel_template = {{body}} -main_branches = main -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = CHANGELOG.${config:format} -skip_fragments = README.* -entry_title_template = {%% if version %%}{{ version }} -- {%% endif %%}{{ date.strftime('%%Y-%%m-%%d') }} diff --git a/ouroboros-network-testing/ouroboros-network-testing.cabal b/ouroboros-network-testing/ouroboros-network-testing.cabal deleted file mode 100644 index a9972c7b63c..00000000000 --- a/ouroboros-network-testing/ouroboros-network-testing.cabal +++ /dev/null @@ -1,121 +0,0 @@ -cabal-version: 3.0 -name: ouroboros-network-testing -version: 0.8.3.0 -synopsis: Common modules used for testing in ouroboros-network and ouroboros-consensus -description: Common modules used for testing in ouroboros-network and ouroboros-consensus. -license: Apache-2.0 -license-files: - LICENSE - NOTICE - -copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2024 Intersect -author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts, Karl Knuttson -maintainer: marcin.szamotulski@iohk.io -category: Network -build-type: Simple -extra-doc-files: CHANGELOG.md - -source-repository head - type: git - location: https://github.com/intersectmbo/ouroboros-network - -flag nightly - description: Enable nightly tests - manual: False - default: False - -library - hs-source-dirs: src - -- At this experiment/prototype stage everything is exposed. - -- This has to be tidied up once the design becomes clear. - exposed-modules: - Test.Ouroboros.Network.Data.AbsBearerInfo - Test.Ouroboros.Network.Data.Script - Test.Ouroboros.Network.Data.Signal - Test.Ouroboros.Network.QuickCheck - Test.Ouroboros.Network.Serialise - Test.Ouroboros.Network.Utils - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - other-extensions: - BangPatterns - DataKinds - EmptyCase - ExistentialQuantification - FlexibleContexts - FlexibleInstances - FunctionalDependencies - GADTSyntax - GADTs - GeneralizedNewtypeDeriving - MultiParamTypeClasses - NamedFieldPuns - OverloadedStrings - PolyKinds - RankNTypes - RecordWildCards - ScopedTypeVariables - TemplateHaskell - TupleSections - TypeApplications - TypeFamilies - TypeInType - - build-depends: - QuickCheck, - base >=4.14 && <4.22, - cborg >=0.2.1 && <0.3, - containers, - contra-tracer, - deepseq, - deque ^>=0.4, - io-classes:{io-classes, si-timers, strict-stm} ^>=1.8.0.1, - io-sim, - network-mux, - pretty-simple, - psqueues >=0.2.3 && <0.3, - serialise >=0.2 && <0.3, - tasty, - tasty-expected-failure, - - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -fno-ignore-asserts - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - - if flag(nightly) - cpp-options: -DNIGHTLY - -test-suite test - type: exitcode-stdio-1.0 - main-is: Main.hs - hs-source-dirs: test - other-modules: Test.Ouroboros.Network.Data.AbsBearerInfo.Test - build-depends: - QuickCheck, - base >=4.14 && <4.22, - ouroboros-network-testing, - tasty, - tasty-quickcheck, - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - ghc-options: - -rtsopts - -threaded - -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wno-unticked-promoted-constructors - -Wunused-packages diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index f13a69170b6..7d4df338f90 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -32,6 +32,11 @@ flag ipv6 -- Default to False since travis lacks IPv6 support default: False +flag nightly + description: Enable nightly tests + manual: False + default: False + source-repository head type: git location: https://github.com/intersectmbo/ouroboros-network @@ -246,8 +251,8 @@ library framework network-mux ^>=0.9.1, nothunks, nothunks ^>=0.1.4 || ^>=0.2, + ouroboros-network:tests-lib, ouroboros-network-api ^>=0.17, - ouroboros-network-testing, psqueues, quiet, random ^>=1.2, @@ -258,6 +263,92 @@ library framework build-depends: Win32 >=2.5.4.1 && <3.0 hs-source-dirs: framework +library tests-lib + import: ghc-options + visibility: public + hs-source-dirs: tests-lib/lib + -- At this experiment/prototype stage everything is exposed. + -- This has to be tidied up once the design becomes clear. + exposed-modules: + Test.Ouroboros.Network.Data.AbsBearerInfo + Test.Ouroboros.Network.Data.Script + Test.Ouroboros.Network.Data.Signal + Test.Ouroboros.Network.QuickCheck + Test.Ouroboros.Network.Serialise + Test.Ouroboros.Network.Utils + + other-extensions: + BangPatterns + DataKinds + EmptyCase + ExistentialQuantification + FlexibleContexts + FlexibleInstances + FunctionalDependencies + GADTSyntax + GADTs + GeneralizedNewtypeDeriving + MultiParamTypeClasses + NamedFieldPuns + OverloadedStrings + PolyKinds + RankNTypes + RecordWildCards + ScopedTypeVariables + TemplateHaskell + TupleSections + TypeApplications + TypeFamilies + TypeInType + + build-depends: + QuickCheck, + base >=4.14 && <4.22, + cborg >=0.2.1 && <0.3, + containers, + contra-tracer, + deepseq, + deque ^>=0.4, + io-classes:{io-classes, si-timers, strict-stm} ^>=1.8.0.1, + io-sim, + network-mux, + pretty-simple, + psqueues >=0.2.3 && <0.3, + serialise >=0.2 && <0.3, + tasty, + tasty-expected-failure, + + ghc-options: + -Wall + -Wno-unticked-promoted-constructors + -fno-ignore-asserts + -Wcompat + -Wincomplete-uni-patterns + -Wincomplete-record-updates + -Wpartial-fields + -Widentities + -Wredundant-constraints + + if flag(nightly) + cpp-options: -DNIGHTLY + +test-suite tests-lib-tests + import: ghc-options + type: exitcode-stdio-1.0 + main-is: Main.hs + hs-source-dirs: tests-lib/tests + other-modules: Test.Ouroboros.Network.Data.AbsBearerInfo.Test + build-depends: + QuickCheck, + base >=4.14 && <4.22, + ouroboros-network:tests-lib, + tasty, + tasty-quickcheck, + + ghc-options: + -rtsopts + -threaded + library framework-tests-lib import: ghc-options visibility: public @@ -281,9 +372,8 @@ library framework-tests-lib io-classes:{io-classes, si-timers, strict-stm}, io-sim, network-mux, - ouroboros-network:framework, + ouroboros-network:{framework, tests-lib}, ouroboros-network-api, - ouroboros-network-testing, random, serialise, typed-protocols:{typed-protocols, examples}, @@ -311,9 +401,8 @@ test-suite framework-sim-tests io-sim, monoidal-synchronisation, network-mux, - ouroboros-network:{framework, framework-tests-lib}, + ouroboros-network:{framework, framework-tests-lib, tests-lib}, ouroboros-network-api, - ouroboros-network-testing, pretty-simple, psqueues, quickcheck-instances, @@ -661,9 +750,8 @@ library protocols-tests-lib io-sim, network, network-mux, - ouroboros-network:{framework, mock, protocols}, + ouroboros-network:{framework, mock, protocols, tests-lib}, ouroboros-network-api, - ouroboros-network-testing, pipes, quickcheck-instances, serialise, @@ -685,10 +773,8 @@ test-suite protocols-tests build-depends: QuickCheck ^>=2.16, base >=4.14 && <4.22, - ouroboros-network:{mock, protocols-tests-lib}, - ouroboros-network:protocols-tests-lib, + ouroboros-network:{mock, protocols-tests-lib, tests-lib}, ouroboros-network-api, - ouroboros-network-testing ^>=0.8, tasty, tasty-quickcheck, @@ -812,9 +898,8 @@ library ouroboros-network-tests-lib network, network-mux, nothunks, - ouroboros-network:{ouroboros-network, cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, protocols, protocols-tests-lib}, + ouroboros-network:{ouroboros-network, cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, protocols, protocols-tests-lib, tests-lib}, ouroboros-network-api, - ouroboros-network-testing ^>=0.8.3, pipes, pretty-simple, psqueues, @@ -911,9 +996,8 @@ test-suite ouroboros-network-io-tests monoidal-synchronisation, network, network-mux, - ouroboros-network:{cardano-diffusion, framework, mock, protocols, protocols-tests-lib}, + ouroboros-network:{cardano-diffusion, framework, mock, protocols, protocols-tests-lib, tests-lib}, ouroboros-network-api, - ouroboros-network-testing ^>=0.8.1, serialise, tasty, tasty-quickcheck, diff --git a/ouroboros-network-testing/src/Test/Ouroboros/Network/Data/AbsBearerInfo.hs b/ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Data/AbsBearerInfo.hs similarity index 100% rename from ouroboros-network-testing/src/Test/Ouroboros/Network/Data/AbsBearerInfo.hs rename to ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Data/AbsBearerInfo.hs diff --git a/ouroboros-network-testing/src/Test/Ouroboros/Network/Data/Script.hs b/ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Data/Script.hs similarity index 100% rename from ouroboros-network-testing/src/Test/Ouroboros/Network/Data/Script.hs rename to ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Data/Script.hs diff --git a/ouroboros-network-testing/src/Test/Ouroboros/Network/Data/Signal.hs b/ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Data/Signal.hs similarity index 100% rename from ouroboros-network-testing/src/Test/Ouroboros/Network/Data/Signal.hs rename to ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Data/Signal.hs diff --git a/ouroboros-network-testing/src/Test/Ouroboros/Network/QuickCheck.hs b/ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/QuickCheck.hs similarity index 100% rename from ouroboros-network-testing/src/Test/Ouroboros/Network/QuickCheck.hs rename to ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/QuickCheck.hs diff --git a/ouroboros-network-testing/src/Test/Ouroboros/Network/Serialise.hs b/ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Serialise.hs similarity index 100% rename from ouroboros-network-testing/src/Test/Ouroboros/Network/Serialise.hs rename to ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Serialise.hs diff --git a/ouroboros-network-testing/src/Test/Ouroboros/Network/Utils.hs b/ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Utils.hs similarity index 100% rename from ouroboros-network-testing/src/Test/Ouroboros/Network/Utils.hs rename to ouroboros-network/tests-lib/lib/Test/Ouroboros/Network/Utils.hs diff --git a/ouroboros-network-testing/test/Main.hs b/ouroboros-network/tests-lib/tests/Main.hs similarity index 100% rename from ouroboros-network-testing/test/Main.hs rename to ouroboros-network/tests-lib/tests/Main.hs diff --git a/ouroboros-network-testing/test/Test/Ouroboros/Network/Data/AbsBearerInfo/Test.hs b/ouroboros-network/tests-lib/tests/Test/Ouroboros/Network/Data/AbsBearerInfo/Test.hs similarity index 100% rename from ouroboros-network-testing/test/Test/Ouroboros/Network/Data/AbsBearerInfo/Test.hs rename to ouroboros-network/tests-lib/tests/Test/Ouroboros/Network/Data/AbsBearerInfo/Test.hs From deaff171e4a6fb4b1d3c856af67f4edafa556e5f Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 16 Sep 2025 10:15:45 +0200 Subject: [PATCH 07/24] Moved ouroboros-network-api to ouroboros-newtork * `ouroboros-network-api` -> `ouroboros-network:api` in `ouroboros-network/api/lib` * `ouroboros-network-api:test` -> `ouroboros-network:api-tests` in `ouroboros-network/api/tests` * `ouroboros-network-api:bench-anchored-fragment` -> `ouroboros-network:api-bench` in `ouroboros-network/api/bench` --- cabal.project | 1 - cardano-client/cardano-client.cabal | 3 +- dmq-node/dmq-node.cabal | 9 +- ouroboros-network-api/CHANGELOG.md | 310 ------------------ ouroboros-network-api/LICENSE | 177 ---------- ouroboros-network-api/NOTICE | 14 - .../ouroboros-network-api.cabal | 152 --------- .../api/bench}/BenchBlock.hs | 0 .../api/bench}/Main.hs | 0 .../api/lib}/Cardano/Network/ConsensusMode.hs | 0 .../Network/PeerSelection/Bootstrap.hs | 0 .../Network/PeerSelection/LocalRootPeers.hs | 0 .../Network/PeerSelection/PeerTrustable.hs | 0 .../api/lib}/Cardano/Network/Types.hs | 0 .../Ouroboros/Network/AnchoredFragment.hs | 0 .../api/lib}/Ouroboros/Network/AnchoredSeq.hs | 0 .../api/lib}/Ouroboros/Network/Block.hs | 0 .../Network/BlockFetch/ConsensusInterface.hs | 0 .../lib}/Ouroboros/Network/CodecCBORTerm.hs | 0 .../lib}/Ouroboros/Network/ControlMessage.hs | 0 .../api/lib}/Ouroboros/Network/Handshake.hs | 0 .../Ouroboros/Network/Handshake/Acceptable.hs | 0 .../Ouroboros/Network/Handshake/Queryable.hs | 0 .../api/lib}/Ouroboros/Network/Magic.hs | 0 .../Ouroboros/Network/NodeToClient/Version.hs | 0 .../Ouroboros/Network/NodeToNode/Version.hs | 0 .../Network/PeerSelection/LedgerPeers/Type.hs | 0 .../PeerSelection/LedgerPeers/Utils.hs | 0 .../Network/PeerSelection/PeerAdvertise.hs | 0 .../Network/PeerSelection/PeerMetric/Type.hs | 0 .../Network/PeerSelection/PeerSharing.hs | 0 .../PeerSelection/PeerSharing/Codec.hs | 0 .../Network/PeerSelection/RelayAccessPoint.hs | 0 .../api/lib}/Ouroboros/Network/Point.hs | 0 .../lib}/Ouroboros/Network/Protocol/Limits.hs | 0 .../api/lib}/Ouroboros/Network/SizeInBytes.hs | 0 .../lib}/Ouroboros/Network/Util/ShowProxy.hs | 0 .../api/tests}/Main.hs | 0 .../Network/PeerSelection/RelayAccessPoint.hs | 0 .../20251009_154638_coot_dmq_ntc_socket.md | 0 ...tin.mista_node_to_node_version_nothunks.md | 0 .../changelog.d/scriv.ini | 2 +- ouroboros-network/ouroboros-network.cabal | 161 +++++++-- 43 files changed, 132 insertions(+), 697 deletions(-) delete mode 100644 ouroboros-network-api/CHANGELOG.md delete mode 100644 ouroboros-network-api/LICENSE delete mode 100644 ouroboros-network-api/NOTICE delete mode 100644 ouroboros-network-api/ouroboros-network-api.cabal rename {ouroboros-network-api/bench-anchored-fragment => ouroboros-network/api/bench}/BenchBlock.hs (100%) rename {ouroboros-network-api/bench-anchored-fragment => ouroboros-network/api/bench}/Main.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Cardano/Network/ConsensusMode.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Cardano/Network/PeerSelection/Bootstrap.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Cardano/Network/PeerSelection/LocalRootPeers.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Cardano/Network/PeerSelection/PeerTrustable.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Cardano/Network/Types.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/AnchoredFragment.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/AnchoredSeq.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/Block.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/BlockFetch/ConsensusInterface.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/CodecCBORTerm.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/ControlMessage.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/Handshake.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/Handshake/Acceptable.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/Handshake/Queryable.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/Magic.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/NodeToClient/Version.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/NodeToNode/Version.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/PeerSelection/LedgerPeers/Type.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/PeerSelection/LedgerPeers/Utils.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/PeerSelection/PeerAdvertise.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/PeerSelection/PeerMetric/Type.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/PeerSelection/PeerSharing.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/Point.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/Protocol/Limits.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/SizeInBytes.hs (100%) rename {ouroboros-network-api/src => ouroboros-network/api/lib}/Ouroboros/Network/Util/ShowProxy.hs (100%) rename {ouroboros-network-api/test => ouroboros-network/api/tests}/Main.hs (100%) rename {ouroboros-network-api/test => ouroboros-network/api/tests}/Test/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs (100%) rename {ouroboros-network-api => ouroboros-network}/changelog.d/20251009_154638_coot_dmq_ntc_socket.md (100%) rename {ouroboros-network-api => ouroboros-network}/changelog.d/20251010_112341_agustin.mista_node_to_node_version_nothunks.md (100%) rename {ouroboros-network-api => ouroboros-network}/changelog.d/scriv.ini (89%) diff --git a/cabal.project b/cabal.project index 6cd85a505c0..10ffab78a43 100644 --- a/cabal.project +++ b/cabal.project @@ -24,7 +24,6 @@ packages: ./cardano-ping ./monoidal-synchronisation ./network-mux ./ouroboros-network - ./ouroboros-network-api ./ntp-client ./cardano-client ./dmq-node diff --git a/cardano-client/cardano-client.cabal b/cardano-client/cardano-client.cabal index 9296552b6c8..f2c8c861479 100644 --- a/cardano-client/cardano-client.cabal +++ b/cardano-client/cardano-client.cabal @@ -28,8 +28,7 @@ library contra-tracer >=0.1 && <0.3, io-classes:si-timers ^>=1.8.0.1, network-mux ^>=0.9, - ouroboros-network:{cardano-diffusion, framework} ^>=0.23, - ouroboros-network-api ^>=0.17, + ouroboros-network:{api, cardano-diffusion, framework} ^>=0.23, ghc-options: -Wall diff --git a/dmq-node/dmq-node.cabal b/dmq-node/dmq-node.cabal index bb9601b8c35..d31a75489fd 100644 --- a/dmq-node/dmq-node.cabal +++ b/dmq-node/dmq-node.cabal @@ -103,8 +103,7 @@ library network ^>=3.2.7, network-mux ^>=0.9.1, optparse-applicative ^>=0.18, - ouroboros-network:{ouroboros-network, framework, orphan-instances, protocols} ^>=0.23, - ouroboros-network-api ^>=0.17, + ouroboros-network:{ouroboros-network, api, framework, orphan-instances, protocols} ^>=0.23, random ^>=1.2, singletons, text >=1.2.4 && <2.2, @@ -135,8 +134,7 @@ executable dmq-node dmq-node, kes-agent-crypto, optparse-applicative, - ouroboros-network, - ouroboros-network-api, + ouroboros-network:{ouroboros-network, api}, random, text, @@ -172,8 +170,7 @@ test-suite dmq-test io-classes, io-sim, kes-agent-crypto, - ouroboros-network:{framework, protocols, protocols-tests-lib, tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, framework, protocols, protocols-tests-lib, tests-lib}, quickcheck-instances, serialise, tasty, diff --git a/ouroboros-network-api/CHANGELOG.md b/ouroboros-network-api/CHANGELOG.md deleted file mode 100644 index 79a93bcca8c..00000000000 --- a/ouroboros-network-api/CHANGELOG.md +++ /dev/null @@ -1,310 +0,0 @@ -# ouroboros-network-api changelog - - - - -## 0.17.0.0 -- 2025-09-10 - -### Breaking changes - -* Simplify type of `headerForgeUTCTime` in `BlockFetchConsensusInterface`, and - remove the supporting type `FromConsensus`. -* Changed `BlockFetchConsensusInterface` to support dynamic (weighted) chain - comparisons. - -### Non-breaking changes - -## 0.16.0.0 -- 2025-07-21 - -### Breaking changes - -* Added `encodeLedgerPeerSnapshot` and `decodeLedgerPeerSnapshot`; removed - `{To,From}CBOR` instances for `LedgerPeerSnapshot`. - -## 0.15.0.0 -- 2025-06-28 - -### Breaking changes - -* Added `NodeToClientV_21`. - -### Non-breaking changes - -* `IsLedgerPeer` added to `Ouroboros.Network.LedgerPeers.Types` module. -* Added `ProtocolTimeLimitsWithRnd` to `Ouroboros.Network.Protocol.Limits` -* Derived `Bounded` instance for `SizeInBytes`. - -## 0.14.1.0 -- 2025-07-17 - -### Breaking changes - -### Non-breaking changes - -* Allow/restore capability for peer sharing in `InitiatorOnly` mode - -## 0.14.0.0 - 2025-05-13 - -### Breaking changes - -* Removed `NodeToNodeV_13` - -### Non-breaking changes - -## 0.13.0.0 -- 2025-02-25 - -### Breaking changes - -* Added `NodeToClientV_20`. -- Moved `Ouroboros.Network.ConsensusMode` to `Cardano.Network.ConsensusMode` -- Moved `Ouroboros.Network.PeerSelection.Bootstrap` to `Cardano.Network.PeerSelection.Bootstrap` -- Moved `Ouroboros.Network.PeerSelection.LocalRootPeers` to `Cardano.Network.PeerSelection.LocalRootPeers` -- Moved `Ouroboros.Network.PeerSelection.PeerTrustable` to `Cardano.Network.PeerSelection.PeerTrustable` -- Created `Cardano.Network.Types` and moved Cardano specific types such as - `LedgerStateJudgement` and `NumberOfBigLedgerPeers` from - `Ouroboros.Network.PeerSelection.LedgerPeers/Type` to there. -- Removed `lpGetLedgerStateJudgment` from `LedgerConsensusInterface` and added - `extraAPI` type parameter to it. -* Removed `DomainAccessPoint` type -* Added `RelayAccessSRVDomain` tag to `RelayAccessPoint` -* Removed `RelayAccessPointCoded` type -* Bumped LedgerPeerSnapshot version to 2 to directly - leverage JSON and CBOR instances for `RelayAccessPoint` - -## 0.12.0.0 -- 2025-01-02 - -### Breaking changes - -* Removed deprecated APIs - * `getLegacyTipBlockNo` - * `legacyTip` - * `toLegacyTip` -* Dropped all node-to-client versions < `NodeToClientV_16`. - -### Non-breaking changes - -## 0.11.0.0 -- 2024-10-17 - -### Breaking changes - -* Renamed: - * `accBigPoolStake` -> `accumulateBigLedgerStake` - and `reRelativeStake` -> `recomputeRelativeStake` -* Using `typed-protocols-0.3.0.0`. -* Added `NodeToClientV_19`. -* Removed `blockForgeUTCTime` from `BlockFetchConsensusInterface`. - -### Non-breaking changes - -* Added `ConsensusMode` which must be passed to start diffusion in the - appropriate mode -* added `compareLedgerPeerSnapshotApproximate` function which compares - two snapshots for approximate equality wrt stake distribution and - fully qualified domain names. -* Added `MinBigLedgerPeersForTrustedState` type of values indicating - the minimum number of active big ledger peers needed to signal - trusted state when finishing syncing in Genesis mode. - -## 0.10.0.0 -- 2024-10-11 - -### Breaking changes - -* Removed `NodeToNodeV_12` and older as these are unable - to cross the hard fork boundary. -* Removed `WhetherReceivingTentativeBlocks` used to - distinguish whether a node version is pipelining-enabled, - used in older `NodeToNodeVersion` -* Added `NodeToNodeV_14` to identify nodes supporting Chang+1 HF -* Added `NodeToClientV_18` - -### Non-breaking changes - -## 0.9.0.1 -- 2024-08-27 - -### Breaking changes - -### Non-breaking changes - -* bump for bad ref in chap for 0.9.0.0 - -## 0.9.0.0 -- 2024-08-22 - -### Breaking changes - -* Added `NodeToClientV_17` to support new local state queries - -### Non-Breaking changes - -## 0.8.0.0 -- 2024-08-07 - -### Breaking changes - -* `LedgerPeersKind` was transplanted here from o-network because this - functionality needs to be exposed in support of Genesis work and - generation of a big ledger peer snapshot. - -### Non-Breaking changes - -* Transplanted `accBigPoolStake` and `reRelativeStake` from ouroboros-network - `LedgerPeers` module to expose functionality that facilitates serializing - of big ledger peers via LocalStateQuery miniprotocol. -* Introduced `LedgerPeerSnapshot` type for values of big ledger peers obtained - from the ledger at a particular volatile tip. - * New type supports CBOR & JSON for serialisation purposes. - * Ledger peer snapshot is versioned in case changes need to be made to the - encoding format in the future. - -* Added `Measure` and `BoundedMeasure` instances for `SizeInBytes`. - -* Make it build with ghc-9.10 - -* Added Monoid and Semigroup instances for `SizeInBytes` - -## 0.7.3.0 -- 2024-06-07 - -### Breaking changes - -### Non-Breaking changes - -- Bump io-sim and io-classes -* Added `ShowProxy SlotNo` instance -* Added `AnchoredSeq.splitAtMeasure` -* Added `AnchoredFragment.splitAtSlot` - -## 0.7.2.0 -- 2024-05-07 - -### Breaking changes - -### Non-Breaking changes - -* Added `OutboundConnectionsState` data type - -## 0.7.1.0 -- 2024-03-14 - -### Breaking changes - -### Non-Breaking changes - -* Added `Generic` and `NFData` instance derivations for `NodeToClientVersion` - data type - -## 0.7.0.0 -- 2024-02-21 - -### Breaking changes - -* Changed `LedgerConsensusInterface` type: - `LedgerConsensusInterface` now has to fill 3 STM actions: - * `lpGetLatestSlot :: STM m (WithOrigin SlotNo)` - * `lpGetLedgerStateJudgment :: STM m LedgerStateJudgement` - * `lpGetLedgerPeers :: STM m [(PoolStake, NonEmpty RelayAccessPoint)]` - -* Added `PeerTrustable` flag -* Added `UseBootstrapPeers`, this data type is now a flag - to enable/disable bootstrap peers usage. -* Added `UseLedgerPeers` flag with an indirection layer to `UseLedgerAfter` - -### Non-breaking changes - -## 0.6.3.0 -- 2024-01-22 - -### Non-breaking changes - -- CI requires me to add an entry here even though I merely updated a comment on - `NodeToClientV_16` mention new `ImmutableTip` argument in LocalStateQuery - mini protocol - -## 0.6.2.0 -- 2023-12-14 - -### Non-breaking changes - -* Refactored `NodeToNodeVersionData` decoder. - -## 0.6.1.0 -- 2023-11-29 - -### Non-breaking changes - -* Fixed handshake codec: disabled `PeerSharing` for `node-to-node` versions 11 and 12. -* Disable `PeerSharing` with `InitiatorOnly` nodes, since they do not run - peer sharing server side and can not reply to requests. -* Fixed `Acceptable` instance of `NodeToNodeVersionData` to only negotiate - `PeerSharing` if diffusion mode is `InitiatorAndResponder` -* ghc-9.8 support. - -## 0.6.0.1 -- 2023-11-16 - -### Non-breaking changes - -* Use `io-sim-1.3.0.0`. - -## 0.6.0.0 -- 2023-11-02 - -### Breaking changes - -* Remove `PeerSharingPrivate` option from the `PeerSharing` data type. -* Rename `NoPeerSharing` and `PeerSharingPublic` to `PeerSharingDisabled` and - `PeerSharingEnabled`, respectively. -* Add new `NodeToNodeV_13` that encodes and decodes the updated `PeerSharing` flag data - type. -* Move remote address codec to 'src/Ouroboros/Network/NodeToNode/Version.hs'. -* Make remote address codec receive 'NodeToNodeVersion'. - -### Non-breaking changes - -* Restructured `decodeTerm` to prevent an impossible case and eliminate the - associated `error`. - -## 0.5.1.1 -- 2023-10-26 - -### Non-breaking changes - -* Depend on `type-protocols-0.1.1.0`. - -## 0.5.1.0 -- 2023-08-09 - -### Breaking changes - -### Non-breaking changes - -* Added `IsBigLedgerPeer` type to - `Ouroboros.Network.PeerSelection.LedgerPeers.Type`. - -## 0.5.0.0 -- 2023-05-15 - -* Swapped `NodeToClientV_15` with `NodeToClientV_16`, e.g. handshake query - comes with `V_15` and Conway with `V_16`. -* Swapped `NodeToNodeV_11` with `NodeToNodeV_12`, e.g. handshake query moved to - `V_11` and Conway moved to `V_12`. `V_11` also comes with handshake support - for peer sharing. - -## 0.4.0.0 -- 2023-05-08 - -Depracated release, use `0.5` instead. - -### Breakin changes - -* Added `NodeToNodeV_12` and `NodeToClientV_16` which support handshake query. -* Added `query` flag to `NodeToClientVersionData` and `NodeToNodeVersionData`. -* Introduced `HandshakeCallbacks` record. - -### Non-breaking changes - -* Added `Querable` type class. - -## 0.3.0.0 -- 2023-04-28 - -* Removed `encoddedTipSize` and `encodedPointSize`. -* `HeaderHash` is kind polymorphic. - -## 0.2.0.0 -- 2023-04-19 - -### Breaking - -- Integration of latest `cardano-ledger` and `cardano-base`. -- Peer Sharing integration - - New PeerAdvertise data type file - - New PeerSharing data type file -- Remove foldr in favour of toOldestFirst - -### Non-breaking - -## 0.1.0.0 -- 2022-11-17 - -* Initial release diff --git a/ouroboros-network-api/LICENSE b/ouroboros-network-api/LICENSE deleted file mode 100644 index f433b1a53f5..00000000000 --- a/ouroboros-network-api/LICENSE +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/ouroboros-network-api/NOTICE b/ouroboros-network-api/NOTICE deleted file mode 100644 index 3efdc24424e..00000000000 --- a/ouroboros-network-api/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/ouroboros-network-api/ouroboros-network-api.cabal b/ouroboros-network-api/ouroboros-network-api.cabal deleted file mode 100644 index 6ec413aad56..00000000000 --- a/ouroboros-network-api/ouroboros-network-api.cabal +++ /dev/null @@ -1,152 +0,0 @@ -cabal-version: 3.0 -name: ouroboros-network-api -version: 0.17.0.0 -synopsis: A networking api shared with ouroboros-consensus -description: A networking api shared with ouroboros-consensus. -license: Apache-2.0 -license-files: - LICENSE - NOTICE - -copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect -author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts, Karl Knutsson -maintainer: marcin.szamotulski@iohk.io -category: Network -build-type: Simple -extra-doc-files: CHANGELOG.md - -flag asserts - description: Enable assertions - manual: False - default: False - -library - hs-source-dirs: src - exposed-modules: - Cardano.Network.ConsensusMode - Cardano.Network.PeerSelection.Bootstrap - Cardano.Network.PeerSelection.LocalRootPeers - Cardano.Network.PeerSelection.PeerTrustable - Cardano.Network.Types - Ouroboros.Network.AnchoredFragment - Ouroboros.Network.AnchoredSeq - Ouroboros.Network.Block - Ouroboros.Network.BlockFetch.ConsensusInterface - Ouroboros.Network.CodecCBORTerm - Ouroboros.Network.ControlMessage - Ouroboros.Network.Handshake - Ouroboros.Network.Handshake.Acceptable - Ouroboros.Network.Handshake.Queryable - Ouroboros.Network.Magic - Ouroboros.Network.NodeToClient.Version - Ouroboros.Network.NodeToNode.Version - Ouroboros.Network.PeerSelection.LedgerPeers.Type - Ouroboros.Network.PeerSelection.LedgerPeers.Utils - Ouroboros.Network.PeerSelection.PeerAdvertise - Ouroboros.Network.PeerSelection.PeerMetric.Type - Ouroboros.Network.PeerSelection.PeerSharing - Ouroboros.Network.PeerSelection.PeerSharing.Codec - Ouroboros.Network.PeerSelection.RelayAccessPoint - Ouroboros.Network.Point - Ouroboros.Network.Protocol.Limits - Ouroboros.Network.SizeInBytes - Ouroboros.Network.Util.ShowProxy - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - build-depends: - aeson, - base >=4.14 && <4.22, - base16-bytestring, - bytestring >=0.10 && <0.13, - cardano-binary, - cardano-slotting, - cardano-strict-containers, - cborg >=0.2.1 && <0.3, - containers, - contra-tracer, - deepseq, - dns, - io-classes:{io-classes, si-timers, strict-stm} ^>=1.8.0.1, - iproute ^>=1.7.15, - measures, - network ^>=3.2.7, - network-mux ^>=0.9, - nothunks, - quiet, - random, - serialise >=0.2 && <0.3, - text >=1.2 && <2.2, - typed-protocols ^>=1.1, - - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wunused-packages - - if flag(asserts) - ghc-options: -fno-ignore-asserts - -test-suite test - type: exitcode-stdio-1.0 - main-is: Main.hs - hs-source-dirs: test - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - other-modules: - Test.Ouroboros.Network.PeerSelection.RelayAccessPoint - - build-depends: - QuickCheck, - aeson, - base >=4.14 && <4.22, - bytestring, - cardano-binary, - cborg, - iproute, - ouroboros-network-api, - tasty, - tasty-quickcheck, - with-utf8, - - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wunused-packages - -rtsopts - -benchmark bench-anchored-fragment - type: exitcode-stdio-1.0 - default-extensions: ImportQualifiedPost - hs-source-dirs: bench-anchored-fragment - default-language: Haskell2010 - main-is: Main.hs - other-modules: - BenchBlock - - build-depends: - base >=4.14 && <4.22, - bytestring, - cryptohash-sha256, - nothunks, - ouroboros-network-api, - tasty-bench, - - ghc-options: - -Wall - -Wunused-packages - -rtsopts - "-with-rtsopts=-A32m -T" - -fproc-alignment=64 diff --git a/ouroboros-network-api/bench-anchored-fragment/BenchBlock.hs b/ouroboros-network/api/bench/BenchBlock.hs similarity index 100% rename from ouroboros-network-api/bench-anchored-fragment/BenchBlock.hs rename to ouroboros-network/api/bench/BenchBlock.hs diff --git a/ouroboros-network-api/bench-anchored-fragment/Main.hs b/ouroboros-network/api/bench/Main.hs similarity index 100% rename from ouroboros-network-api/bench-anchored-fragment/Main.hs rename to ouroboros-network/api/bench/Main.hs diff --git a/ouroboros-network-api/src/Cardano/Network/ConsensusMode.hs b/ouroboros-network/api/lib/Cardano/Network/ConsensusMode.hs similarity index 100% rename from ouroboros-network-api/src/Cardano/Network/ConsensusMode.hs rename to ouroboros-network/api/lib/Cardano/Network/ConsensusMode.hs diff --git a/ouroboros-network-api/src/Cardano/Network/PeerSelection/Bootstrap.hs b/ouroboros-network/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs similarity index 100% rename from ouroboros-network-api/src/Cardano/Network/PeerSelection/Bootstrap.hs rename to ouroboros-network/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs diff --git a/ouroboros-network-api/src/Cardano/Network/PeerSelection/LocalRootPeers.hs b/ouroboros-network/api/lib/Cardano/Network/PeerSelection/LocalRootPeers.hs similarity index 100% rename from ouroboros-network-api/src/Cardano/Network/PeerSelection/LocalRootPeers.hs rename to ouroboros-network/api/lib/Cardano/Network/PeerSelection/LocalRootPeers.hs diff --git a/ouroboros-network-api/src/Cardano/Network/PeerSelection/PeerTrustable.hs b/ouroboros-network/api/lib/Cardano/Network/PeerSelection/PeerTrustable.hs similarity index 100% rename from ouroboros-network-api/src/Cardano/Network/PeerSelection/PeerTrustable.hs rename to ouroboros-network/api/lib/Cardano/Network/PeerSelection/PeerTrustable.hs diff --git a/ouroboros-network-api/src/Cardano/Network/Types.hs b/ouroboros-network/api/lib/Cardano/Network/Types.hs similarity index 100% rename from ouroboros-network-api/src/Cardano/Network/Types.hs rename to ouroboros-network/api/lib/Cardano/Network/Types.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/AnchoredFragment.hs b/ouroboros-network/api/lib/Ouroboros/Network/AnchoredFragment.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/AnchoredFragment.hs rename to ouroboros-network/api/lib/Ouroboros/Network/AnchoredFragment.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/AnchoredSeq.hs b/ouroboros-network/api/lib/Ouroboros/Network/AnchoredSeq.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/AnchoredSeq.hs rename to ouroboros-network/api/lib/Ouroboros/Network/AnchoredSeq.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/Block.hs b/ouroboros-network/api/lib/Ouroboros/Network/Block.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/Block.hs rename to ouroboros-network/api/lib/Ouroboros/Network/Block.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/BlockFetch/ConsensusInterface.hs b/ouroboros-network/api/lib/Ouroboros/Network/BlockFetch/ConsensusInterface.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/BlockFetch/ConsensusInterface.hs rename to ouroboros-network/api/lib/Ouroboros/Network/BlockFetch/ConsensusInterface.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/CodecCBORTerm.hs b/ouroboros-network/api/lib/Ouroboros/Network/CodecCBORTerm.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/CodecCBORTerm.hs rename to ouroboros-network/api/lib/Ouroboros/Network/CodecCBORTerm.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/ControlMessage.hs b/ouroboros-network/api/lib/Ouroboros/Network/ControlMessage.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/ControlMessage.hs rename to ouroboros-network/api/lib/Ouroboros/Network/ControlMessage.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/Handshake.hs b/ouroboros-network/api/lib/Ouroboros/Network/Handshake.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/Handshake.hs rename to ouroboros-network/api/lib/Ouroboros/Network/Handshake.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/Handshake/Acceptable.hs b/ouroboros-network/api/lib/Ouroboros/Network/Handshake/Acceptable.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/Handshake/Acceptable.hs rename to ouroboros-network/api/lib/Ouroboros/Network/Handshake/Acceptable.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/Handshake/Queryable.hs b/ouroboros-network/api/lib/Ouroboros/Network/Handshake/Queryable.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/Handshake/Queryable.hs rename to ouroboros-network/api/lib/Ouroboros/Network/Handshake/Queryable.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/Magic.hs b/ouroboros-network/api/lib/Ouroboros/Network/Magic.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/Magic.hs rename to ouroboros-network/api/lib/Ouroboros/Network/Magic.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/NodeToClient/Version.hs b/ouroboros-network/api/lib/Ouroboros/Network/NodeToClient/Version.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/NodeToClient/Version.hs rename to ouroboros-network/api/lib/Ouroboros/Network/NodeToClient/Version.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/NodeToNode/Version.hs b/ouroboros-network/api/lib/Ouroboros/Network/NodeToNode/Version.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/NodeToNode/Version.hs rename to ouroboros-network/api/lib/Ouroboros/Network/NodeToNode/Version.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/PeerSelection/LedgerPeers/Type.hs b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/LedgerPeers/Type.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/PeerSelection/LedgerPeers/Type.hs rename to ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/LedgerPeers/Type.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/PeerSelection/LedgerPeers/Utils.hs b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/LedgerPeers/Utils.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/PeerSelection/LedgerPeers/Utils.hs rename to ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/LedgerPeers/Utils.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerAdvertise.hs b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerAdvertise.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerAdvertise.hs rename to ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerAdvertise.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerMetric/Type.hs b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerMetric/Type.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerMetric/Type.hs rename to ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerMetric/Type.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerSharing.hs b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerSharing.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerSharing.hs rename to ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerSharing.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs rename to ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs rename to ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/Point.hs b/ouroboros-network/api/lib/Ouroboros/Network/Point.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/Point.hs rename to ouroboros-network/api/lib/Ouroboros/Network/Point.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/Protocol/Limits.hs b/ouroboros-network/api/lib/Ouroboros/Network/Protocol/Limits.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/Protocol/Limits.hs rename to ouroboros-network/api/lib/Ouroboros/Network/Protocol/Limits.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/SizeInBytes.hs b/ouroboros-network/api/lib/Ouroboros/Network/SizeInBytes.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/SizeInBytes.hs rename to ouroboros-network/api/lib/Ouroboros/Network/SizeInBytes.hs diff --git a/ouroboros-network-api/src/Ouroboros/Network/Util/ShowProxy.hs b/ouroboros-network/api/lib/Ouroboros/Network/Util/ShowProxy.hs similarity index 100% rename from ouroboros-network-api/src/Ouroboros/Network/Util/ShowProxy.hs rename to ouroboros-network/api/lib/Ouroboros/Network/Util/ShowProxy.hs diff --git a/ouroboros-network-api/test/Main.hs b/ouroboros-network/api/tests/Main.hs similarity index 100% rename from ouroboros-network-api/test/Main.hs rename to ouroboros-network/api/tests/Main.hs diff --git a/ouroboros-network-api/test/Test/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs b/ouroboros-network/api/tests/Test/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs similarity index 100% rename from ouroboros-network-api/test/Test/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs rename to ouroboros-network/api/tests/Test/Ouroboros/Network/PeerSelection/RelayAccessPoint.hs diff --git a/ouroboros-network-api/changelog.d/20251009_154638_coot_dmq_ntc_socket.md b/ouroboros-network/changelog.d/20251009_154638_coot_dmq_ntc_socket.md similarity index 100% rename from ouroboros-network-api/changelog.d/20251009_154638_coot_dmq_ntc_socket.md rename to ouroboros-network/changelog.d/20251009_154638_coot_dmq_ntc_socket.md diff --git a/ouroboros-network-api/changelog.d/20251010_112341_agustin.mista_node_to_node_version_nothunks.md b/ouroboros-network/changelog.d/20251010_112341_agustin.mista_node_to_node_version_nothunks.md similarity index 100% rename from ouroboros-network-api/changelog.d/20251010_112341_agustin.mista_node_to_node_version_nothunks.md rename to ouroboros-network/changelog.d/20251010_112341_agustin.mista_node_to_node_version_nothunks.md diff --git a/ouroboros-network-api/changelog.d/scriv.ini b/ouroboros-network/changelog.d/scriv.ini similarity index 89% rename from ouroboros-network-api/changelog.d/scriv.ini rename to ouroboros-network/changelog.d/scriv.ini index bc01e0d0432..01e1dad40a4 100644 --- a/ouroboros-network-api/changelog.d/scriv.ini +++ b/ouroboros-network/changelog.d/scriv.ini @@ -2,7 +2,7 @@ format = md insert_marker = Changelog entries md_header_level = 2 -version = literal: ouroboros-network-api.cabal: version +version = literal: ouroboros-network.cabal: version categories = Breaking, Non-Breaking start_marker = scriv-insert-here end_marker = scriv-end-here diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 7d4df338f90..4f61ee2b7ac 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -65,6 +65,115 @@ common ghc-options-tests import: ghc-options ghc-options: -Wno-redundant-constraints +library api + import: ghc-options + visibility: public + hs-source-dirs: api/lib + exposed-modules: + Cardano.Network.ConsensusMode + Cardano.Network.PeerSelection.Bootstrap + Cardano.Network.PeerSelection.LocalRootPeers + Cardano.Network.PeerSelection.PeerTrustable + Cardano.Network.Types + Ouroboros.Network.AnchoredFragment + Ouroboros.Network.AnchoredSeq + Ouroboros.Network.Block + Ouroboros.Network.BlockFetch.ConsensusInterface + Ouroboros.Network.CodecCBORTerm + Ouroboros.Network.ControlMessage + Ouroboros.Network.Handshake + Ouroboros.Network.Handshake.Acceptable + Ouroboros.Network.Handshake.Queryable + Ouroboros.Network.Magic + Ouroboros.Network.NodeToClient.Version + Ouroboros.Network.NodeToNode.Version + Ouroboros.Network.PeerSelection.LedgerPeers.Type + Ouroboros.Network.PeerSelection.LedgerPeers.Utils + Ouroboros.Network.PeerSelection.PeerAdvertise + Ouroboros.Network.PeerSelection.PeerMetric.Type + Ouroboros.Network.PeerSelection.PeerSharing + Ouroboros.Network.PeerSelection.PeerSharing.Codec + Ouroboros.Network.PeerSelection.RelayAccessPoint + Ouroboros.Network.Point + Ouroboros.Network.Protocol.Limits + Ouroboros.Network.SizeInBytes + Ouroboros.Network.Util.ShowProxy + + build-depends: + aeson, + base >=4.14 && <4.22, + base16-bytestring, + bytestring >=0.10 && <0.13, + cardano-binary, + cardano-slotting, + cardano-strict-containers, + cborg >=0.2.1 && <0.3, + containers, + contra-tracer, + deepseq, + dns, + io-classes:{io-classes, si-timers, strict-stm} ^>=1.8.0.1, + iproute ^>=1.7.15, + measures, + network ^>=3.2.7, + network-mux ^>=0.9, + nothunks, + quiet, + random, + serialise >=0.2 && <0.3, + text >=1.2 && <2.2, + typed-protocols ^>=1.1, + +test-suite api-tests + import: ghc-options + type: exitcode-stdio-1.0 + main-is: Main.hs + hs-source-dirs: api/tests + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + other-modules: + Test.Ouroboros.Network.PeerSelection.RelayAccessPoint + + build-depends: + QuickCheck, + aeson, + base >=4.14 && <4.22, + bytestring, + cardano-binary, + cborg, + iproute, + ouroboros-network:api, + tasty, + tasty-quickcheck, + with-utf8, + + ghc-options: + -rtsopts + +benchmark api-bench + type: exitcode-stdio-1.0 + default-extensions: ImportQualifiedPost + hs-source-dirs: api/bench + default-language: Haskell2010 + main-is: Main.hs + other-modules: + BenchBlock + + build-depends: + base >=4.14 && <4.22, + bytestring, + cryptohash-sha256, + nothunks, + ouroboros-network:api, + tasty-bench, + + ghc-options: + -Wall + -Wunused-packages + -rtsopts + "-with-rtsopts=-A32m -T" + -fproc-alignment=64 + library import: ghc-options hs-source-dirs: lib @@ -178,8 +287,7 @@ library network ^>=3.2.7, network-mux, nothunks, - ouroboros-network:{framework, protocols} ^>=0.23, - ouroboros-network-api ^>=0.17, + ouroboros-network:{api, framework, protocols} ^>=0.23, psqueues >=0.2.3 && <0.3, random, strict-checked-vars ^>=0.2, @@ -251,8 +359,7 @@ library framework network-mux ^>=0.9.1, nothunks, nothunks ^>=0.1.4 || ^>=0.2, - ouroboros-network:tests-lib, - ouroboros-network-api ^>=0.17, + ouroboros-network:{api, tests-lib}, psqueues, quiet, random ^>=1.2, @@ -372,8 +479,7 @@ library framework-tests-lib io-classes:{io-classes, si-timers, strict-stm}, io-sim, network-mux, - ouroboros-network:{framework, tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, framework, tests-lib}, random, serialise, typed-protocols:{typed-protocols, examples}, @@ -401,8 +507,7 @@ test-suite framework-sim-tests io-sim, monoidal-synchronisation, network-mux, - ouroboros-network:{framework, framework-tests-lib, tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, framework, framework-tests-lib, tests-lib}, pretty-simple, psqueues, quickcheck-instances, @@ -444,8 +549,7 @@ test-suite framework-io-tests monoidal-synchronisation, network, network-mux, - ouroboros-network:{framework, framework-tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, framework, framework-tests-lib}, random, tasty, tasty-quickcheck, @@ -500,8 +604,7 @@ library orphan-instances iproute, network, network-mux, - ouroboros-network:{ouroboros-network, cardano-diffusion, framework, protocols}, - ouroboros-network-api ^>=0.17, + ouroboros-network:{ouroboros-network, api, cardano-diffusion, framework, protocols}, text, typed-protocols, @@ -516,8 +619,7 @@ executable demo-ping-pong contra-tracer, directory, network-mux, - ouroboros-network:framework, - ouroboros-network-api, + ouroboros-network:{api, framework}, typed-protocols:examples, executable demo-connection-manager @@ -533,8 +635,7 @@ executable demo-connection-manager network, network-mux, optparse-applicative, - ouroboros-network:framework, - ouroboros-network-api, + ouroboros-network:{api, framework}, random, typed-protocols:{typed-protocols, examples}, @@ -597,8 +698,7 @@ library cardano-diffusion monoidal-synchronisation, network ^>=3.2.7, network-mux, - ouroboros-network:{ouroboros-network, framework, protocols}, - ouroboros-network-api ^>=0.17, + ouroboros-network:{ouroboros-network, api, framework, protocols}, random, typed-protocols:{typed-protocols, stateful} ^>=1.1, @@ -682,7 +782,7 @@ library protocols deepseq, io-classes:{io-classes, si-timers} ^>=1.8.0.1, nothunks, - ouroboros-network-api ^>=0.17, + ouroboros-network:api, quiet, random, serialise, @@ -750,8 +850,7 @@ library protocols-tests-lib io-sim, network, network-mux, - ouroboros-network:{framework, mock, protocols, tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, framework, mock, protocols, tests-lib}, pipes, quickcheck-instances, serialise, @@ -773,8 +872,7 @@ test-suite protocols-tests build-depends: QuickCheck ^>=2.16, base >=4.14 && <4.22, - ouroboros-network:{mock, protocols-tests-lib, tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, mock, protocols-tests-lib, tests-lib}, tasty, tasty-quickcheck, @@ -805,8 +903,7 @@ test-suite protocols-cddl filepath, mtl, network, - ouroboros-network:{framework, mock, protocols, protocols-tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, framework, mock, protocols, protocols-tests-lib}, process-extras, quickcheck-instances, serialise, @@ -836,8 +933,7 @@ test-suite protocols-bench containers, deepseq, network, - ouroboros-network:{framework, protocols, protocols-tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, framework, protocols, protocols-tests-lib}, tasty-bench, typed-protocols:{typed-protocols, stateful}, @@ -867,7 +963,7 @@ library mock containers, hashable, nothunks, - ouroboros-network-api, + ouroboros-network:api, serialise, time, @@ -898,8 +994,7 @@ library ouroboros-network-tests-lib network, network-mux, nothunks, - ouroboros-network:{ouroboros-network, cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, protocols, protocols-tests-lib, tests-lib}, - ouroboros-network-api, + ouroboros-network:{ouroboros-network, api, cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, protocols, protocols-tests-lib, tests-lib}, pipes, pretty-simple, psqueues, @@ -996,8 +1091,7 @@ test-suite ouroboros-network-io-tests monoidal-synchronisation, network, network-mux, - ouroboros-network:{cardano-diffusion, framework, mock, protocols, protocols-tests-lib, tests-lib}, - ouroboros-network-api, + ouroboros-network:{api, cardano-diffusion, framework, mock, protocols, protocols-tests-lib, tests-lib}, serialise, tasty, tasty-quickcheck, @@ -1032,8 +1126,7 @@ executable demo-chain-sync io-classes:{si-timers, strict-stm}, network-mux, optparse-applicative, - ouroboros-network:{ouroboros-network, cardano-diffusion, framework, mock, protocols}, - ouroboros-network-api, + ouroboros-network:{ouroboros-network, api, cardano-diffusion, framework, mock, protocols}, random, serialise, typed-protocols, From 4d4b5226f49418d51d0a1c47b18b17b3f117408f Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 16 Sep 2025 12:45:56 +0200 Subject: [PATCH 08/24] ouroboros-network:api - moved NodeTo{Node,Client} under Cardano name space --- dmq-node/app/Main.hs | 7 +++--- dmq-node/src/DMQ/Configuration.hs | 2 +- dmq-node/src/DMQ/NodeToNode.hs | 2 +- dmq-node/src/DMQ/NodeToNode/Version.hs | 2 +- dmq-node/test/Test/DMQ/NodeToNode.hs | 2 +- .../Network/NodeToClient/Version.hs | 2 +- .../Network/NodeToNode/Version.hs | 24 ++----------------- .../lib/Ouroboros/Network/DiffusionMode.hs | 21 ++++++++++++++++ .../PeerSelection/PeerSharing/Codec.hs | 5 ++-- .../Cardano/Network/NodeToClient.hs | 3 ++- .../Cardano/Network/NodeToNode.hs | 3 ++- ouroboros-network/demo/connection-manager.hs | 2 +- .../Network/ConnectionManager/Core.hs | 2 +- .../Network/ConnectionManager/Types.hs | 2 +- .../Network/Protocol/Handshake/Codec.hs | 10 ++++---- .../Ouroboros/Network/ConnectionManager.hs | 2 +- .../Test/Ouroboros/Network/Server/Sim.hs | 2 +- .../Network/ConnectionManager/Experiments.hs | 2 +- .../Network/Diffusion/Configuration.hs | 2 +- .../lib/Ouroboros/Network/Diffusion/Types.hs | 3 ++- .../Governor/EstablishedPeers.hs | 2 +- .../Network/PeerSelection/Governor/Types.hs | 7 +++--- .../Network/PeerSelection/PeerStateActions.hs | 2 +- .../PeerSelection/State/LocalRootPeers.hs | 3 ++- .../Network/TxSubmission/Inbound/V1.hs | 3 ++- .../Ouroboros/Network/OrphanInstances.hs | 2 +- ouroboros-network/ouroboros-network.cabal | 5 ++-- ouroboros-network/protocols/bench/Main.hs | 5 ++-- ouroboros-network/protocols/cddl/Main.hs | 8 +++---- .../Network/Protocol/LocalStateQuery/Codec.hs | 2 +- .../Network/Protocol/LocalTxMonitor/Codec.hs | 2 +- .../Network/Protocol/Handshake/Test.hs | 10 ++++---- .../Protocol/PeerSharing/Codec/CDDL.hs | 4 +++- .../Cardano/Network/NodeToClient/Version.hs | 3 ++- .../Cardano/Network/NodeToNode/Version.hs | 3 ++- .../lib/Test/Ouroboros/Network/BlockFetch.hs | 3 ++- .../Test/Ouroboros/Network/Diffusion/Node.hs | 2 +- .../Network/Diffusion/Node/Kernel.hs | 3 ++- .../Network/Diffusion/Node/MiniProtocols.hs | 2 +- .../Diffusion/Testnet/Cardano/Simulation.hs | 2 +- .../Ouroboros/Network/NodeToClient/Version.hs | 3 ++- .../Ouroboros/Network/NodeToNode/Version.hs | 3 ++- .../Test/Ouroboros/Network/PeerSelection.hs | 2 +- .../PeerSelection/Cardano/MockEnvironment.hs | 2 +- .../Network/PeerSelection/Instances.hs | 2 +- .../Network/PeerSelection/RootPeersDNS.hs | 2 +- 46 files changed, 101 insertions(+), 86 deletions(-) rename ouroboros-network/api/lib/{Ouroboros => Cardano}/Network/NodeToClient/Version.hs (99%) rename ouroboros-network/api/lib/{Ouroboros => Cardano}/Network/NodeToNode/Version.hs (88%) create mode 100644 ouroboros-network/api/lib/Ouroboros/Network/DiffusionMode.hs diff --git a/dmq-node/app/Main.hs b/dmq-node/app/Main.hs index 346bd5622de..edbda5e1d5f 100644 --- a/dmq-node/app/Main.hs +++ b/dmq-node/app/Main.hs @@ -32,7 +32,8 @@ import DMQ.Diffusion.Arguments import DMQ.Diffusion.NodeKernel (mempool, withNodeKernel) import DMQ.Handlers.TopLevel (toplevelExceptionHandler) import DMQ.NodeToClient qualified as NtC -import DMQ.NodeToNode (dmqCodecs, dmqLimitsAndTimeouts, ntnApps) +import DMQ.NodeToNode (NodeToNodeVersion, dmqCodecs, dmqLimitsAndTimeouts, + ntnApps) import DMQ.Protocol.LocalMsgSubmission.Codec import DMQ.Protocol.SigSubmission.Type (Sig (..)) import DMQ.Tracer @@ -111,8 +112,8 @@ runDMQ commandLineConfig = do (dmqCodecs -- TODO: `maxBound :: Cardano.Network.NodeToNode.NodeToNodeVersion` -- is unsafe here! - (encodeRemoteAddress maxBound) - (decodeRemoteAddress maxBound)) + (encodeRemoteAddress (maxBound :: NodeToNodeVersion)) + (decodeRemoteAddress (maxBound :: NodeToNodeVersion))) dmqLimitsAndTimeouts defaultSigDecisionPolicy dmqNtCApps = diff --git a/dmq-node/src/DMQ/Configuration.hs b/dmq-node/src/DMQ/Configuration.hs index e97b99db3d6..d3b9c8c69aa 100644 --- a/dmq-node/src/DMQ/Configuration.hs +++ b/dmq-node/src/DMQ/Configuration.hs @@ -63,8 +63,8 @@ import Ouroboros.Network.Diffusion.Configuration (BlockProducerOrRelay (..), import Ouroboros.Network.Diffusion.Topology (NetworkTopology (..), producerAddresses) import Ouroboros.Network.Diffusion.Types qualified as Diffusion +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Magic (NetworkMagic (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.OrphanInstances () import Ouroboros.Network.PeerSelection.Governor.Types (PeerSelectionTargets (..), makePublicPeerSelectionStateVar) diff --git a/dmq-node/src/DMQ/NodeToNode.hs b/dmq-node/src/DMQ/NodeToNode.hs index a931ff0c43e..9ff7a3acc7c 100644 --- a/dmq-node/src/DMQ/NodeToNode.hs +++ b/dmq-node/src/DMQ/NodeToNode.hs @@ -66,6 +66,7 @@ import Ouroboros.Network.Channel (Channel) import Ouroboros.Network.ConnectionId (ConnectionId (..)) import Ouroboros.Network.Context (ExpandedInitiatorContext (..), ResponderContext (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Driver.Limits (runAnnotatedPeerWithLimits, runPeerWithLimits, runPipelinedAnnotatedPeerWithLimits) import Ouroboros.Network.Driver.Simple (TraceSendRecv) @@ -79,7 +80,6 @@ import Ouroboros.Network.Mux (MiniProtocol (..), MiniProtocolCb (..), OuroborosBundleWithExpandedCtx, RunMiniProtocol (..), StartOnDemandOrEagerly (..), TemperatureBundle (..), WithProtocolTemperature (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection (PeerSharing (..)) import Ouroboros.Network.PeerSharing (bracketPeerSharingClient, peerSharingClient, peerSharingServer) diff --git a/dmq-node/src/DMQ/NodeToNode/Version.hs b/dmq-node/src/DMQ/NodeToNode/Version.hs index e7e9ee152fd..752c97ac9dc 100644 --- a/dmq-node/src/DMQ/NodeToNode/Version.hs +++ b/dmq-node/src/DMQ/NodeToNode/Version.hs @@ -21,10 +21,10 @@ import GHC.Generics (Generic) import Ouroboros.Network.CodecCBORTerm (CodecCBORTerm (..)) import Ouroboros.Network.ConnectionManager.Types (DataFlow (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Handshake.Acceptable (Acceptable (..)) import Ouroboros.Network.Handshake.Queryable (Queryable (..)) import Ouroboros.Network.Magic (NetworkMagic (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection (PeerSharing (..)) import Ouroboros.Network.Protocol.Handshake (Accept (..)) diff --git a/dmq-node/test/Test/DMQ/NodeToNode.hs b/dmq-node/test/Test/DMQ/NodeToNode.hs index f9a2c1b9fbd..74960ee131e 100644 --- a/dmq-node/test/Test/DMQ/NodeToNode.hs +++ b/dmq-node/test/Test/DMQ/NodeToNode.hs @@ -4,8 +4,8 @@ module Test.DMQ.NodeToNode (tests) where import Ouroboros.Network.CodecCBORTerm +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Magic (NetworkMagic (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import DMQ.NodeToNode diff --git a/ouroboros-network/api/lib/Ouroboros/Network/NodeToClient/Version.hs b/ouroboros-network/api/lib/Cardano/Network/NodeToClient/Version.hs similarity index 99% rename from ouroboros-network/api/lib/Ouroboros/Network/NodeToClient/Version.hs rename to ouroboros-network/api/lib/Cardano/Network/NodeToClient/Version.hs index a3aaeb8de9f..fd6fd1d1ae0 100644 --- a/ouroboros-network/api/lib/Ouroboros/Network/NodeToClient/Version.hs +++ b/ouroboros-network/api/lib/Cardano/Network/NodeToClient/Version.hs @@ -3,7 +3,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} -module Ouroboros.Network.NodeToClient.Version +module Cardano.Network.NodeToClient.Version ( NodeToClientVersion (..) , NodeToClientVersionData (..) , nodeToClientCodecCBORTerm diff --git a/ouroboros-network/api/lib/Ouroboros/Network/NodeToNode/Version.hs b/ouroboros-network/api/lib/Cardano/Network/NodeToNode/Version.hs similarity index 88% rename from ouroboros-network/api/lib/Ouroboros/Network/NodeToNode/Version.hs rename to ouroboros-network/api/lib/Cardano/Network/NodeToNode/Version.hs index cfac201106d..7aa2ba51f0b 100644 --- a/ouroboros-network/api/lib/Ouroboros/Network/NodeToNode/Version.hs +++ b/ouroboros-network/api/lib/Cardano/Network/NodeToNode/Version.hs @@ -3,7 +3,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} -module Ouroboros.Network.NodeToNode.Version +module Cardano.Network.NodeToNode.Version ( NodeToNodeVersion (..) , NodeToNodeVersionData (..) , DiffusionMode (..) @@ -21,6 +21,7 @@ import Control.DeepSeq import GHC.Generics import NoThunks.Class (NoThunks) import Ouroboros.Network.CodecCBORTerm +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Handshake.Acceptable (Accept (..), Acceptable (..)) import Ouroboros.Network.Handshake.Queryable (Queryable (..)) import Ouroboros.Network.Magic @@ -89,27 +90,6 @@ nodeToNodeVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm } , Nothing) - --- | The flag which indicates whether the node runs only initiator or both --- initiator or responder node. --- --- This data structure has two proposes: --- --- * instruct the diffusion layer if it should listen on incoming connections; --- --- * it is communicated via 'NodeToNodeVersionData' during handshake --- negotiation. In non-p2p mode we always send 'InitiatorOnlyDiffusionMode', --- in p2p mode we send exactly what the diffusion is given. In non-p2p mode --- every connection outbound port is ephemeral, the remote side cannot connect --- to it, however in p2p mode the outbound port is actually the port on which --- the node is listening (if it runs in 'InitiatorAndResponderDiffusionMode'). --- -data DiffusionMode - = InitiatorOnlyDiffusionMode - | InitiatorAndResponderDiffusionMode - deriving (Eq, Ord, Show) - - -- | Version data for NodeToNode protocol -- data NodeToNodeVersionData = NodeToNodeVersionData diff --git a/ouroboros-network/api/lib/Ouroboros/Network/DiffusionMode.hs b/ouroboros-network/api/lib/Ouroboros/Network/DiffusionMode.hs new file mode 100644 index 00000000000..2d98f262aa9 --- /dev/null +++ b/ouroboros-network/api/lib/Ouroboros/Network/DiffusionMode.hs @@ -0,0 +1,21 @@ +module Ouroboros.Network.DiffusionMode (DiffusionMode (..)) where + + +-- | The flag which indicates whether the node runs only initiator or both +-- initiator or responder node. +-- +-- This data structure has two proposes: +-- +-- * instruct the diffusion layer if it should listen on incoming connections; +-- +-- * it is communicated via 'NodeToNodeVersionData' during handshake +-- negotiation. In non-p2p mode we always send 'InitiatorOnlyDiffusionMode', +-- in p2p mode we send exactly what the diffusion is given. In non-p2p mode +-- every connection outbound port is ephemeral, the remote side cannot connect +-- to it, however in p2p mode the outbound port is actually the port on which +-- the node is listening (if it runs in 'InitiatorAndResponderDiffusionMode'). +-- +data DiffusionMode + = InitiatorOnlyDiffusionMode + | InitiatorAndResponderDiffusionMode + deriving (Eq, Ord, Show) diff --git a/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs index ef64f26e212..40bbe4b2676 100644 --- a/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs +++ b/ouroboros-network/api/lib/Ouroboros/Network/PeerSelection/PeerSharing/Codec.hs @@ -11,7 +11,6 @@ import Codec.CBOR.Decoding qualified as CBOR import Codec.CBOR.Encoding qualified as CBOR import Network.Socket (PortNumber, SockAddr (..)) -import Ouroboros.Network.NodeToNode.Version (NodeToNodeVersion (..)) encodePortNumber :: PortNumber -> CBOR.Encoding encodePortNumber = CBOR.encodeWord16 . fromIntegral @@ -27,7 +26,7 @@ decodePortNumber = fromIntegral <$> CBOR.decodeWord16 --- -- /Invariant:/ not a unix socket address type. --- -encodeRemoteAddress :: NodeToNodeVersion -> SockAddr -> CBOR.Encoding +encodeRemoteAddress :: version -> SockAddr -> CBOR.Encoding encodeRemoteAddress _ = \case SockAddrInet pn w -> CBOR.encodeListLen 3 <> CBOR.encodeWord 0 @@ -47,7 +46,7 @@ encodeRemoteAddress _ = \case -- -- See the network design document for more details -- -decodeRemoteAddress :: NodeToNodeVersion -> CBOR.Decoder s SockAddr +decodeRemoteAddress :: version -> CBOR.Decoder s SockAddr decodeRemoteAddress _ = do _ <- CBOR.decodeListLen tok <- CBOR.decodeWord diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToClient.hs b/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToClient.hs index af3503b77cc..92292b4f505 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToClient.hs +++ b/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToClient.hs @@ -64,12 +64,13 @@ import Network.Mux qualified as Mx import Network.TypedProtocol.Peer.Client import Network.TypedProtocol.Stateful.Peer.Client qualified as Stateful +import Cardano.Network.NodeToClient.Version + import Ouroboros.Network.Context import Ouroboros.Network.Driver (TraceSendRecv (..)) import Ouroboros.Network.Driver.Limits (ProtocolLimitFailure (..)) import Ouroboros.Network.IOManager import Ouroboros.Network.Mux -import Ouroboros.Network.NodeToClient.Version import Ouroboros.Network.Protocol.ChainSync.Client as ChainSync import Ouroboros.Network.Protocol.ChainSync.Type qualified as ChainSync import Ouroboros.Network.Protocol.Handshake.Codec diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToNode.hs b/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToNode.hs index f8e1c702267..9e5aa4766c5 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToNode.hs +++ b/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToNode.hs @@ -82,6 +82,8 @@ import Network.Mux qualified as Mx import Network.Socket (Socket, StructLinger (..)) import Network.Socket qualified as Socket +import Cardano.Network.NodeToNode.Version + import Ouroboros.Network.ConnectionManager.Types (DataFlow (..), ExceptionInHandler (..)) import Ouroboros.Network.Context @@ -89,7 +91,6 @@ import Ouroboros.Network.ControlMessage (ControlMessage (..)) import Ouroboros.Network.Driver (TraceSendRecv (..)) import Ouroboros.Network.Driver.Limits (ProtocolLimitFailure (..)) import Ouroboros.Network.Mux -import Ouroboros.Network.NodeToNode.Version import Ouroboros.Network.PeerSelection.Governor.Types (PeerSelectionTargets (..)) import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise (..)) diff --git a/ouroboros-network/demo/connection-manager.hs b/ouroboros-network/demo/connection-manager.hs index 916e3f24ca5..bdc7740086a 100644 --- a/ouroboros-network/demo/connection-manager.hs +++ b/ouroboros-network/demo/connection-manager.hs @@ -66,13 +66,13 @@ import Ouroboros.Network.ConnectionManager.Core qualified as CM import Ouroboros.Network.ConnectionManager.State qualified as CM import Ouroboros.Network.ConnectionManager.Types import Ouroboros.Network.Context +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.InboundGovernor qualified as InboundGovernor import Ouroboros.Network.InboundGovernor.InformationChannel (newInformationChannel) import Ouroboros.Network.IOManager import Ouroboros.Network.Mux import Ouroboros.Network.MuxMode -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.Protocol.Handshake import Ouroboros.Network.Protocol.Handshake.Unversioned import Ouroboros.Network.RethrowPolicy diff --git a/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Core.hs b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Core.hs index 65b8785593e..3f1fcf9ff3e 100644 --- a/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Core.hs +++ b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Core.hs @@ -64,11 +64,11 @@ import Ouroboros.Network.ConnectionManager.State (ConnStateIdSupply, ConnectionManagerState, ConnectionState (..), MutableConnState (..)) import Ouroboros.Network.ConnectionManager.State qualified as State import Ouroboros.Network.ConnectionManager.Types +import Ouroboros.Network.DiffusionMode (DiffusionMode (..)) import Ouroboros.Network.InboundGovernor (Event (..), NewConnectionInfo (..)) import Ouroboros.Network.InboundGovernor.InformationChannel (InformationChannel) import Ouroboros.Network.InboundGovernor.InformationChannel qualified as InfoChannel import Ouroboros.Network.MuxMode -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.Server.RateLimiting (AcceptedConnectionsLimit (..)) import Ouroboros.Network.Snocket diff --git a/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Types.hs b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Types.hs index 5d7369b2503..fe1891c5143 100644 --- a/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Types.hs +++ b/ouroboros-network/framework/lib/Ouroboros/Network/ConnectionManager/Types.hs @@ -181,8 +181,8 @@ import Network.Mux.Types qualified as Mux import Ouroboros.Network.ConnectionId (ConnectionId (..)) import Ouroboros.Network.ConnectionManager.ConnMap (ConnMap) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.MuxMode -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) -- | Connection manager supports `IPv4` and `IPv6` addresses. diff --git a/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs index 7512e037da9..11193f96a7e 100644 --- a/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs +++ b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs @@ -41,17 +41,17 @@ import Codec.CBOR.Encoding qualified as CBOR import Codec.CBOR.Read qualified as CBOR import Codec.CBOR.Term qualified as CBOR +import Cardano.Network.NodeToClient.Version (NodeToClientVersion, + nodeToClientVersionCodec) +import Cardano.Network.NodeToNode.Version (NodeToNodeVersion, + nodeToNodeVersionCodec) + import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Driver.Limits import Ouroboros.Network.Protocol.Handshake.Type import Ouroboros.Network.Protocol.Limits -import Ouroboros.Network.NodeToClient.Version (NodeToClientVersion, - nodeToClientVersionCodec) -import Ouroboros.Network.NodeToNode.Version (NodeToNodeVersion, - nodeToNodeVersionCodec) - -- | Codec for version data ('vData' in code) exchanged by the handshake -- protocol. -- diff --git a/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs index 2027a2c0d76..9a25eab1f04 100644 --- a/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs +++ b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/ConnectionManager.hs @@ -63,8 +63,8 @@ import Ouroboros.Network.ConnectionId (ConnectionId (..)) import Ouroboros.Network.ConnectionManager.Core qualified as CM import Ouroboros.Network.ConnectionManager.State qualified as CM import Ouroboros.Network.ConnectionManager.Types +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.MuxMode -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.Server.RateLimiting import Ouroboros.Network.Snocket (Accept (..), Accepted (..), AddressFamily (TestFamily), Snocket (..), TestAddress (..)) diff --git a/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs index 939b520ea83..a6bd00592ec 100644 --- a/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs +++ b/ouroboros-network/framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs @@ -76,12 +76,12 @@ import Ouroboros.Network.ConnectionId import Ouroboros.Network.ConnectionManager.Core qualified as CM import Ouroboros.Network.ConnectionManager.State qualified as CM import Ouroboros.Network.ConnectionManager.Types +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.InboundGovernor qualified as IG import Ouroboros.Network.InboundGovernor.State (ConnectionState (..)) import Ouroboros.Network.InboundGovernor.State qualified as IG import Ouroboros.Network.Mux import Ouroboros.Network.MuxMode -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.Protocol.Handshake.Codec (noTimeLimitsHandshake, timeLimitsHandshake) import Ouroboros.Network.Protocol.Handshake.Unversioned diff --git a/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs b/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs index ae5c88e2d8d..05de7bd770d 100644 --- a/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs +++ b/ouroboros-network/framework/tests-lib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs @@ -85,13 +85,13 @@ import Ouroboros.Network.ConnectionManager.State qualified as CM import Ouroboros.Network.ConnectionManager.Types import Ouroboros.Network.Context import Ouroboros.Network.ControlMessage +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Driver.Limits import Ouroboros.Network.InboundGovernor qualified as InboundGovernor import Ouroboros.Network.InboundGovernor.InformationChannel (newInformationChannel) import Ouroboros.Network.Mux import Ouroboros.Network.MuxMode -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.Protocol.Handshake import Ouroboros.Network.Protocol.Handshake.Unversioned import Ouroboros.Network.RethrowPolicy diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs index decc029656f..18fa655a7dc 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs @@ -40,7 +40,7 @@ import Ouroboros.Network.ConnectionManager.Core (defaultProtocolIdleTimeout, defaultResetTimeout, defaultTimeWaitTimeout) import Ouroboros.Network.Diffusion.Policies (closeConnectionTimeout, deactivateTimeout, peerMetricsConfiguration) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.PeerSelection.Governor.Types (PeerSelectionTargets (..)) import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs index 6dd1f135a37..b396e128b98 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs @@ -32,6 +32,7 @@ module Ouroboros.Network.Diffusion.Types , AbstractTransitionTrace , IG.RemoteTransitionTrace , SRVPrefix + , DiffusionMode (..) ) where import Control.Concurrent.Class.MonadSTM.Strict @@ -63,6 +64,7 @@ import Ouroboros.Network.ConnectionManager.Core qualified as CM import Ouroboros.Network.ConnectionManager.State qualified as CM import Ouroboros.Network.ConnectionManager.Types import Ouroboros.Network.Context +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Driver.Simple (TraceSendRecv) import Ouroboros.Network.ExitPolicy import Ouroboros.Network.InboundGovernor qualified as IG @@ -74,7 +76,6 @@ import Ouroboros.Network.Server qualified as Server import Ouroboros.Network.Snocket (FileDescriptor, Snocket) import Ouroboros.Network.Socket (SystemdSocketTracer) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode) import Ouroboros.Network.PeerSelection as PeerSelection import Ouroboros.Network.PeerSelection.Governor.Types import Ouroboros.Network.PeerSelection.RootPeersDNS diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs index bc6e137a817..fecf186f5d8 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs @@ -23,7 +23,7 @@ import Control.Monad.Class.MonadTime.SI import Control.Monad.Class.MonadTimer.SI import System.Random (randomR) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.PeerSelection.Governor.Types import Ouroboros.Network.PeerSelection.LedgerPeers.Type (IsBigLedgerPeer (..)) import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise (..)) diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs index 7e0cb3f75df..f02609d664d 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs @@ -136,17 +136,16 @@ import Data.Semigroup (Min (..)) import Data.Set (Set) import Data.Set qualified as Set import GHC.Stack (HasCallStack) +import System.Random (StdGen) import Control.Applicative (Alternative) +import Control.Concurrent.Class.MonadSTM.Strict import Control.Concurrent.JobPool (Job) import Control.Exception (Exception (..), SomeException, assert) -import Control.Monad.Class.MonadSTM import Control.Monad.Class.MonadTime.SI -import System.Random (StdGen) -import Control.Concurrent.Class.MonadSTM.Strict +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy -import Ouroboros.Network.NodeToNode.Version (DiffusionMode) import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) import Ouroboros.Network.PeerSelection.LedgerPeers.Type import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing) diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerStateActions.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerStateActions.hs index da7b3d270af..fce477e5902 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerStateActions.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerStateActions.hs @@ -59,9 +59,9 @@ import Network.Mux qualified as Mux import Ouroboros.Network.Context import Ouroboros.Network.ControlMessage (ControlMessage (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy import Ouroboros.Network.Mux -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection.Governor.Types (PeerStateActions (..)) import Ouroboros.Network.Protocol.Handshake (HandshakeException) import Ouroboros.Network.RethrowPolicy diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs index b822e14ebc2..ca2c493171e 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs @@ -39,7 +39,8 @@ import Data.Set (Set) import Data.Set qualified as Set import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode) + +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise) diff --git a/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs index f7f6d717202..500cefd78b3 100644 --- a/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs +++ b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs @@ -41,7 +41,8 @@ import Control.Tracer (Tracer, traceWith) import Network.TypedProtocol.Core (N, Nat (..), natToInt) -import Ouroboros.Network.NodeToNode.Version (NodeToNodeVersion) +import Cardano.Network.NodeToNode.Version (NodeToNodeVersion) + import Ouroboros.Network.Protocol.TxSubmission2.Server import Ouroboros.Network.Protocol.TxSubmission2.Type import Ouroboros.Network.TxSubmission.Inbound.V2.Types (ProcessedTxCount (..), diff --git a/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs b/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs index 763876cd2de..b5cce262b3b 100644 --- a/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs +++ b/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs @@ -73,13 +73,13 @@ import Ouroboros.Network.Diffusion.Topology (LocalRootPeersGroup (..), LocalRootPeersGroups (..), NetworkTopology (..), PublicRootPeers (..), RootConfig (..)) import Ouroboros.Network.Diffusion.Types (DiffusionTracer (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Driver.Simple import Ouroboros.Network.ExitPolicy (RepromoteDelay (repromoteDelay)) import Ouroboros.Network.InboundGovernor qualified as InboundGovernor import Ouroboros.Network.InboundGovernor.State (RemoteSt) import Ouroboros.Network.InboundGovernor.State qualified as InboundGovernor import Ouroboros.Network.Mux (MiniProtocolNum (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection hiding (PublicRootPeers) import Ouroboros.Network.PeerSelection.Governor.Types (AssociationMode (..), DebugPeerSelectionState (..), PeerSharingResult (..), diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 4f61ee2b7ac..42447f06cba 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -71,6 +71,8 @@ library api hs-source-dirs: api/lib exposed-modules: Cardano.Network.ConsensusMode + Cardano.Network.NodeToClient.Version + Cardano.Network.NodeToNode.Version Cardano.Network.PeerSelection.Bootstrap Cardano.Network.PeerSelection.LocalRootPeers Cardano.Network.PeerSelection.PeerTrustable @@ -81,12 +83,11 @@ library api Ouroboros.Network.BlockFetch.ConsensusInterface Ouroboros.Network.CodecCBORTerm Ouroboros.Network.ControlMessage + Ouroboros.Network.DiffusionMode Ouroboros.Network.Handshake Ouroboros.Network.Handshake.Acceptable Ouroboros.Network.Handshake.Queryable Ouroboros.Network.Magic - Ouroboros.Network.NodeToClient.Version - Ouroboros.Network.NodeToNode.Version Ouroboros.Network.PeerSelection.LedgerPeers.Type Ouroboros.Network.PeerSelection.LedgerPeers.Utils Ouroboros.Network.PeerSelection.PeerAdvertise diff --git a/ouroboros-network/protocols/bench/Main.hs b/ouroboros-network/protocols/bench/Main.hs index 9bf0d0abd1e..62e5964912a 100644 --- a/ouroboros-network/protocols/bench/Main.hs +++ b/ouroboros-network/protocols/bench/Main.hs @@ -22,9 +22,10 @@ import Network.Socket (SockAddr (..), tupleToHostAddress) import Network.TypedProtocol.Codec import Network.TypedProtocol.Stateful.Codec qualified as Stateful +import Cardano.Network.NodeToClient.Version +import Cardano.Network.NodeToNode.Version + import Ouroboros.Network.Block (SlotNo) -import Ouroboros.Network.NodeToClient.Version -import Ouroboros.Network.NodeToNode.Version import Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL import Ouroboros.Network.Protocol.BlockFetch.Type import Ouroboros.Network.Protocol.ChainSync.Codec.CDDL diff --git a/ouroboros-network/protocols/cddl/Main.hs b/ouroboros-network/protocols/cddl/Main.hs index e243f09517e..0db8dc9f6f6 100644 --- a/ouroboros-network/protocols/cddl/Main.hs +++ b/ouroboros-network/protocols/cddl/Main.hs @@ -61,14 +61,14 @@ import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Magic import Ouroboros.Network.Mock.ConcreteBlock qualified as Concrete (Block) -import Ouroboros.Network.NodeToClient.Version (NodeToClientVersion, +import Cardano.Network.NodeToClient.Version (NodeToClientVersion, NodeToClientVersionData (..), nodeToClientCodecCBORTerm) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..), +import Cardano.Network.NodeToClient.Version qualified as NtCVersion +import Cardano.Network.NodeToNode.Version (DiffusionMode (..), NodeToNodeVersion (..), NodeToNodeVersionData (..), nodeToNodeCodecCBORTerm) +import Cardano.Network.NodeToNode.Version qualified as NtNVersion -import Ouroboros.Network.NodeToClient.Version qualified as NtCVersion -import Ouroboros.Network.NodeToNode.Version qualified as NtNVersion import Ouroboros.Network.PeerSelection.RelayAccessPoint (PortNumber) import Ouroboros.Network.Protocol.BlockFetch.Codec (codecBlockFetch) import Ouroboros.Network.Protocol.BlockFetch.Test () diff --git a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs index 65b39706e0e..3d68270c861 100644 --- a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs +++ b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs @@ -29,7 +29,7 @@ import Network.TypedProtocol.Core import Network.TypedProtocol.Stateful.Codec qualified as Stateful import Network.TypedProtocol.Stateful.Codec.CBOR qualified as Stateful -import Ouroboros.Network.NodeToClient.Version qualified as V +import Cardano.Network.NodeToClient.Version qualified as V import Ouroboros.Network.Protocol.LocalStateQuery.Type diff --git a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs index 08789f5f98d..b0adcbe746f 100644 --- a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs +++ b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs @@ -29,7 +29,7 @@ import Codec.CBOR.Encoding qualified as CBOR import Codec.CBOR.Read qualified as CBOR import Text.Printf -import Ouroboros.Network.NodeToClient.Version qualified as V +import Cardano.Network.NodeToClient.Version qualified as V import Ouroboros.Network.Protocol.LocalTxMonitor.Type codecLocalTxMonitor :: diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs index 525f6e85d32..96ff035344e 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs @@ -48,10 +48,15 @@ import Network.TypedProtocol.Proofs import Test.Ouroboros.Network.Protocol.Utils (prop_codec_cborM, prop_codec_valid_cbor_encoding, splits2, splits3) +import Cardano.Network.NodeToClient.Version as NTC +import Cardano.Network.NodeToNode.Version as NTN + import Ouroboros.Network.Channel import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Driver.Simple (runConnectedPeers, runConnectedPeersAsymmetric, runPeer) +import Ouroboros.Network.Magic +import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Ouroboros.Network.Snocket (TestAddress (..)) import Ouroboros.Network.Snocket qualified as Snocket import Simulation.Network.Snocket @@ -65,11 +70,6 @@ import Ouroboros.Network.Protocol.Handshake.Version import Codec.CBOR.Write qualified as CBOR -import Ouroboros.Network.Magic -import Ouroboros.Network.NodeToClient.Version as NTC -import Ouroboros.Network.NodeToNode.Version as NTN - -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Test.QuickCheck import Test.Tasty (TestTree, testGroup) import Test.Tasty.QuickCheck (testProperty) diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs index 2c8024076d9..ccaab605d3e 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs @@ -4,7 +4,9 @@ import Codec.CBOR.Read qualified as CBOR import Data.ByteString.Lazy qualified as BL import Network.Socket (SockAddr (..)) import Network.TypedProtocol.Codec -import Ouroboros.Network.NodeToNode.Version + +import Cardano.Network.NodeToNode.Version + import Ouroboros.Network.PeerSelection.PeerSharing.Codec (decodeRemoteAddress, encodeRemoteAddress) import Ouroboros.Network.Protocol.PeerSharing.Codec (codecPeerSharing) diff --git a/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToClient/Version.hs b/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToClient/Version.hs index cbe5d30df53..0b9dc61259a 100644 --- a/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToClient/Version.hs +++ b/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToClient/Version.hs @@ -3,9 +3,10 @@ module Test.Cardano.Network.NodeToClient.Version (tests) where +import Cardano.Network.NodeToClient.Version + import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Magic -import Ouroboros.Network.NodeToClient.Version import Test.QuickCheck import Test.Tasty (TestTree, testGroup) diff --git a/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToNode/Version.hs b/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToNode/Version.hs index 030c795c0b3..a5475fb44c5 100644 --- a/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToNode/Version.hs +++ b/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToNode/Version.hs @@ -3,9 +3,10 @@ module Test.Cardano.Network.NodeToNode.Version (tests) where +import Cardano.Network.NodeToNode.Version + import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Magic -import Ouroboros.Network.NodeToNode.Version import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Test.QuickCheck diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs index 7693ef31b7f..9dbaa40bf28 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs @@ -36,6 +36,8 @@ import Control.Monad.Class.MonadTimer.SI import Control.Monad.IOSim import Control.Tracer (Tracer (Tracer), contramap, nullTracer) +import Cardano.Network.NodeToNode.Version (NodeToNodeVersion) + import Ouroboros.Network.ControlMessage (ControlMessage (..)) import Ouroboros.Network.DeltaQ --TODO: could re-export some of the trace types from more convenient places: @@ -51,7 +53,6 @@ import Ouroboros.Network.BlockFetch.Examples import Ouroboros.Network.Driver (TraceSendRecv) import Ouroboros.Network.Mock.Chain qualified as Chain import Ouroboros.Network.Mock.ConcreteBlock -import Ouroboros.Network.NodeToNode.Version (NodeToNodeVersion) import Ouroboros.Network.Protocol.BlockFetch.Type (BlockFetch) import Test.Ouroboros.Network.Utils diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs index db466746e80..2632c041208 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs @@ -83,12 +83,12 @@ import Ouroboros.Network.BlockFetch.ConsensusInterface import Ouroboros.Network.ConnectionManager.State (ConnStateIdSupply) import Ouroboros.Network.ConnectionManager.Types (DataFlow (..)) import Ouroboros.Network.Diffusion qualified as Diffusion +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy (RepromoteDelay (..)) import Ouroboros.Network.Mock.Chain (Chain, toAnchoredFragment, toOldestFirst) import Ouroboros.Network.Mock.ConcreteBlock (Block (..), BlockHeader (..), convertSlotToTimeForTestsAssumingNoHardFork) import Ouroboros.Network.Mock.ProducerState (ChainProducerState (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection.Churn (PeerChurnArgs) import Ouroboros.Network.PeerSelection.Governor (PeerSelectionState (..), PeerSelectionTargets (..), PublicPeerSelectionState (..)) diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs index c841d89882e..8aa1f43ccc5 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs @@ -68,6 +68,7 @@ import Ouroboros.Network.Block (HasFullHeader, SlotNo) import Ouroboros.Network.Block qualified as Block import Ouroboros.Network.BlockFetch import Ouroboros.Network.ConnectionId (ConnectionId (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Handshake.Acceptable (Accept (..), Acceptable (..)) import Ouroboros.Network.Mock.Chain (Chain (..)) import Ouroboros.Network.Mock.Chain qualified as Chain @@ -77,7 +78,6 @@ import Ouroboros.Network.Mock.ProducerState import Simulation.Network.Snocket (AddressType (..), GlobalAddressScheme (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection (PeerSharing, RelayAccessPoint (..)) import Ouroboros.Network.PeerSelection.Governor (PublicPeerSelectionState, makePublicPeerSelectionStateVar) @@ -89,6 +89,7 @@ import Ouroboros.Network.Snocket (TestAddress (..)) import Ouroboros.Network.TxSubmission.Inbound.V2.Registry (SharedTxStateVar, TxChannels (..), TxChannelsVar, TxMempoolSem, newSharedTxStateVar, newTxMempoolSem) + import Test.Ouroboros.Network.Diffusion.Node.ChainDB (ChainDB (..)) import Test.Ouroboros.Network.Diffusion.Node.ChainDB qualified as ChainDB import Test.Ouroboros.Network.Orphans () diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs index c113a81ad8b..315be610caa 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs @@ -81,6 +81,7 @@ import Ouroboros.Network.Context import Ouroboros.Network.ControlMessage (ControlMessage (..)) import Ouroboros.Network.Diffusion qualified as Diffusion import Ouroboros.Network.Diffusion.Policies qualified as Diffusion.Policies +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Driver.Limits import Ouroboros.Network.ExitPolicy (RepromoteDelay (..)) import Ouroboros.Network.KeepAlive @@ -88,7 +89,6 @@ import Ouroboros.Network.Mock.Chain qualified as Chain import Ouroboros.Network.Mock.ConcreteBlock import Ouroboros.Network.Mock.ProducerState import Ouroboros.Network.Mux -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection.PeerMetric (PeerMetrics) import Ouroboros.Network.PeerSelection.PeerSharing qualified as PSTypes import Ouroboros.Network.PeerSharing (PeerSharingAPI, bracketPeerSharingClient, diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs index aee2e882203..00f52df3dc5 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs @@ -109,13 +109,13 @@ import Ouroboros.Network.ConnectionManager.Core qualified as CM import Ouroboros.Network.ConnectionManager.State qualified as CM import Ouroboros.Network.ConnectionManager.Types (AbstractTransitionTrace) import Ouroboros.Network.Diffusion qualified as Diffusion +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.Driver.Limits (ProtocolSizeLimits (..), ProtocolTimeLimits (..)) import Ouroboros.Network.Handshake.Acceptable (Acceptable (acceptableVersion)) import Ouroboros.Network.InboundGovernor (RemoteTransitionTrace) import Ouroboros.Network.InboundGovernor qualified as IG import Ouroboros.Network.Mux (MiniProtocolLimits (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection hiding (peerChurnGovernor, requestPublicRootPeers) import Ouroboros.Network.PeerSelection.Governor qualified as Governor diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToClient/Version.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToClient/Version.hs index ad18f844cdb..dc5ce6832a3 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToClient/Version.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToClient/Version.hs @@ -3,9 +3,10 @@ module Test.Ouroboros.Network.NodeToClient.Version (tests) where +import Cardano.Network.NodeToClient.Version + import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Magic -import Ouroboros.Network.NodeToClient.Version import Test.QuickCheck import Test.Tasty (TestTree, testGroup) diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToNode/Version.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToNode/Version.hs index 28123eb599e..919ca345b2d 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToNode/Version.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/NodeToNode/Version.hs @@ -5,7 +5,8 @@ module Test.Ouroboros.Network.NodeToNode.Version (tests) where import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Magic -import Ouroboros.Network.NodeToNode.Version + +import Cardano.Network.NodeToNode.Version import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Test.QuickCheck diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs index 031453ff5ed..4a71619db41 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs @@ -53,13 +53,13 @@ import Network.DNS qualified as DNS (defaultResolvConf) import Network.Socket (SockAddr) import Cardano.Network.ConsensusMode +import Ouroboros.Network.DiffusionMode import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), requiresBootstrapPeers) import Cardano.Network.PeerSelection.LocalRootPeers (OutboundConnectionsState) import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers import Ouroboros.Network.ExitPolicy (RepromoteDelay (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) import Ouroboros.Network.PeerSelection.Governor hiding (PeerSelectionState (..), peerSharing) import Ouroboros.Network.PeerSelection.Governor qualified as Governor diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs index 90e7cab8ce4..b199ffe0c31 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs @@ -63,8 +63,8 @@ import Control.Monad.IOSim import Control.Tracer (Tracer (..), contramap, traceWith) import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy -import Ouroboros.Network.NodeToNode.Version (DiffusionMode) import Ouroboros.Network.PeerSelection.Governor hiding (PeerSelectionState (..)) import Ouroboros.Network.PeerSelection.Governor qualified as Governor import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs index 98cf3a9c4fb..3da7af42e00 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs @@ -27,7 +27,7 @@ import Data.Word (Word16, Word32, Word64) import Cardano.Network.Diffusion.Configuration qualified as Cardano (srvPrefix) import Cardano.Slotting.Slot (SlotNo (..)) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.PeerSelection.Governor import Ouroboros.Network.PeerSelection.LedgerPeers.Type (AfterSlot (..), diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs index cf9ea9aad26..25433b1ff86 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs @@ -70,7 +70,7 @@ import Control.Monad.Class.MonadTimer.SI qualified as MonadTimer import Control.Monad.IOSim import Control.Tracer (Tracer (Tracer), contramap, nullTracer, traceWith) -import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..)) +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.PeerSelection import Ouroboros.Network.PeerSelection.RootPeersDNS import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency (..), From 6ba6d3118272ac59d7e218af1681eea9faf0e3ad Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 16 Sep 2025 13:02:36 +0200 Subject: [PATCH 09/24] ouroboros-network:api-tests - moved NodeTo{Client,Node}.Version tests --- ouroboros-network/api/tests/Main.hs | 6 +++++- .../tests}/Test/Cardano/Network/NodeToClient/Version.hs | 0 .../tests}/Test/Cardano/Network/NodeToNode/Version.hs | 0 ouroboros-network/ouroboros-network.cabal | 4 ++-- ouroboros-network/tests/sim/Main.hs | 4 ---- 5 files changed, 7 insertions(+), 7 deletions(-) rename ouroboros-network/{tests/lib => api/tests}/Test/Cardano/Network/NodeToClient/Version.hs (100%) rename ouroboros-network/{tests/lib => api/tests}/Test/Cardano/Network/NodeToNode/Version.hs (100%) diff --git a/ouroboros-network/api/tests/Main.hs b/ouroboros-network/api/tests/Main.hs index 25347988273..9a41659f17e 100644 --- a/ouroboros-network/api/tests/Main.hs +++ b/ouroboros-network/api/tests/Main.hs @@ -3,6 +3,8 @@ module Main (main) where import Main.Utf8 (withUtf8) import Test.Tasty +import Test.Cardano.Network.NodeToClient.Version qualified as NodeToClient.Version +import Test.Cardano.Network.NodeToNode.Version qualified as NodeToNode.Version import Test.Ouroboros.Network.PeerSelection.RelayAccessPoint qualified as RelayAccessPoint main :: IO () @@ -11,7 +13,9 @@ main = withUtf8 $ defaultMain tests tests :: TestTree tests = testGroup "ouroboros-network-api" - [ RelayAccessPoint.tests + [ NodeToClient.Version.tests + , NodeToNode.Version.tests + , RelayAccessPoint.tests ] diff --git a/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToClient/Version.hs b/ouroboros-network/api/tests/Test/Cardano/Network/NodeToClient/Version.hs similarity index 100% rename from ouroboros-network/tests/lib/Test/Cardano/Network/NodeToClient/Version.hs rename to ouroboros-network/api/tests/Test/Cardano/Network/NodeToClient/Version.hs diff --git a/ouroboros-network/tests/lib/Test/Cardano/Network/NodeToNode/Version.hs b/ouroboros-network/api/tests/Test/Cardano/Network/NodeToNode/Version.hs similarity index 100% rename from ouroboros-network/tests/lib/Test/Cardano/Network/NodeToNode/Version.hs rename to ouroboros-network/api/tests/Test/Cardano/Network/NodeToNode/Version.hs diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 42447f06cba..8f63260a3f3 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -133,6 +133,8 @@ test-suite api-tests default-language: Haskell2010 default-extensions: ImportQualifiedPost other-modules: + Test.Cardano.Network.NodeToClient.Version + Test.Cardano.Network.NodeToNode.Version Test.Ouroboros.Network.PeerSelection.RelayAccessPoint build-depends: @@ -1012,8 +1014,6 @@ library ouroboros-network-tests-lib exposed-modules: Ouroboros.Network.BlockFetch.Examples Ouroboros.Network.MockNode - Test.Cardano.Network.NodeToClient.Version - Test.Cardano.Network.NodeToNode.Version Test.Cardano.Network.OrphanInstances.Tests Test.Cardano.Network.Version Test.Ouroboros.Network.BlockFetch diff --git a/ouroboros-network/tests/sim/Main.hs b/ouroboros-network/tests/sim/Main.hs index ddf2d90f7eb..68592cbf9e6 100644 --- a/ouroboros-network/tests/sim/Main.hs +++ b/ouroboros-network/tests/sim/Main.hs @@ -3,8 +3,6 @@ module Main (main) where import Main.Utf8 (withUtf8) import Test.Tasty -import Test.Cardano.Network.NodeToClient.Version qualified (tests) -import Test.Cardano.Network.NodeToNode.Version qualified (tests) import Test.Cardano.Network.OrphanInstances.Tests qualified (tests) import Test.Cardano.Network.Version qualified (tests) @@ -36,8 +34,6 @@ tests = [ Test.ChainProducerState.tests -- cardano - , Test.Cardano.Network.NodeToClient.Version.tests - , Test.Cardano.Network.NodeToNode.Version.tests , Test.Cardano.Network.OrphanInstances.Tests.tests , Test.Cardano.Network.Version.tests From e94acfe29c3061b4a1e0d10492513a08a642391a Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 16 Sep 2025 13:09:16 +0200 Subject: [PATCH 10/24] ouroboros-network:api-tests - moved Test.Cardano.Network.Version --- .../Ouroboros/Network/Mock/Chain.hs | 0 .../Network/Mock}/ChainGenerators.hs | 16 ++--- .../Ouroboros/Network/Mock/ConcreteBlock.hs | 0 ouroboros-network/api/tests/Main.hs | 8 ++- .../tests}/Test/Cardano/Network/Version.hs | 10 +-- .../Ouroboros/Network}/AnchoredFragment.hs | 7 ++- .../tests/Test/Ouroboros/Network}/Chain.hs | 4 +- ouroboros-network/ouroboros-network.cabal | 62 +++++++++++-------- ouroboros-network/protocols/cddl/Main.hs | 4 +- .../Network/Protocol/BlockFetch/Test.hs | 2 +- .../Network/Protocol/ChainSync/Test.hs | 4 +- .../Network/Protocol/LocalStateQuery/Test.hs | 2 +- .../Network/Protocol/LocalTxMonitor/Test.hs | 5 +- .../tests-lib/Test/ChainProducerState.hs | 5 +- ouroboros-network/protocols/tests/Main.hs | 9 +-- .../tests/io/Test/Ouroboros/Network/Pipe.hs | 2 +- .../tests/io/Test/Ouroboros/Network/Socket.hs | 2 +- .../lib/Test/Ouroboros/Network/BlockFetch.hs | 2 +- .../lib/Test/Ouroboros/Network/MockNode.hs | 2 +- .../tests/lib/Test/Ouroboros/Network/Mux.hs | 2 +- ouroboros-network/tests/sim/Main.hs | 3 - 21 files changed, 77 insertions(+), 74 deletions(-) rename ouroboros-network/{mock => api/tests-lib}/Ouroboros/Network/Mock/Chain.hs (100%) rename ouroboros-network/{protocols/tests-lib/Test => api/tests-lib/Ouroboros/Network/Mock}/ChainGenerators.hs (98%) rename ouroboros-network/{mock => api/tests-lib}/Ouroboros/Network/Mock/ConcreteBlock.hs (100%) rename ouroboros-network/{tests/lib => api/tests}/Test/Cardano/Network/Version.hs (92%) rename ouroboros-network/{protocols/tests/Test => api/tests/Test/Ouroboros/Network}/AnchoredFragment.hs (99%) rename ouroboros-network/{protocols/tests/Test => api/tests/Test/Ouroboros/Network}/Chain.hs (97%) diff --git a/ouroboros-network/mock/Ouroboros/Network/Mock/Chain.hs b/ouroboros-network/api/tests-lib/Ouroboros/Network/Mock/Chain.hs similarity index 100% rename from ouroboros-network/mock/Ouroboros/Network/Mock/Chain.hs rename to ouroboros-network/api/tests-lib/Ouroboros/Network/Mock/Chain.hs diff --git a/ouroboros-network/protocols/tests-lib/Test/ChainGenerators.hs b/ouroboros-network/api/tests-lib/Ouroboros/Network/Mock/ChainGenerators.hs similarity index 98% rename from ouroboros-network/protocols/tests-lib/Test/ChainGenerators.hs rename to ouroboros-network/api/tests-lib/Ouroboros/Network/Mock/ChainGenerators.hs index 423a2cd0cca..a34d2fbec3c 100644 --- a/ouroboros-network/protocols/tests-lib/Test/ChainGenerators.hs +++ b/ouroboros-network/api/tests-lib/Ouroboros/Network/Mock/ChainGenerators.hs @@ -12,7 +12,7 @@ -- | Arbitrary generators for chains, headers and blocks -- -module Test.ChainGenerators +module Ouroboros.Network.Mock.ChainGenerators ( -- * Arbitrary chains generators -- These generators are used to test various scenarios that require -- a chain: e.g. appending a block to chain, arbitrary updates @@ -25,6 +25,7 @@ module Test.ChainGenerators , TestChainAndRange (..) , TestChainAndPoints (..) , TestChainFork (..) + , TestChainRange (..) -- * Utility functions , genNonNegative , genSlotGap @@ -48,7 +49,6 @@ import Ouroboros.Network.Mock.Chain qualified as Chain import Ouroboros.Network.Mock.ConcreteBlock import Ouroboros.Network.Point (WithOrigin (..), block, blockPointHash, blockPointSlot, fromWithOrigin, origin) -import Ouroboros.Network.Protocol.BlockFetch.Type (ChainRange (..)) import Data.List (scanl') import Test.Cardano.Slotting.Arbitrary () @@ -130,15 +130,17 @@ instance Arbitrary (Point Block) where . shrink . (castPoint :: Point Block -> Point BlockHeader) -instance Arbitrary (ChainRange (Point Block)) where +data TestChainRange = TestChainRange (Point Block) (Point Block) + +instance Arbitrary TestChainRange where arbitrary = do low <- arbitrary high <- arbitrary `suchThat` (\high -> pointSlot low <= pointSlot high) - return (ChainRange low high) + return (TestChainRange low high) - shrink (ChainRange low high) = [ ChainRange low' high' - | (low', high') <- shrink (low, high) - , pointSlot low <= pointSlot high ] + shrink (TestChainRange low high) = [ TestChainRange low' high' + | (low', high') <- shrink (low, high) + , pointSlot low <= pointSlot high ] instance Arbitrary BlockBody where arbitrary = diff --git a/ouroboros-network/mock/Ouroboros/Network/Mock/ConcreteBlock.hs b/ouroboros-network/api/tests-lib/Ouroboros/Network/Mock/ConcreteBlock.hs similarity index 100% rename from ouroboros-network/mock/Ouroboros/Network/Mock/ConcreteBlock.hs rename to ouroboros-network/api/tests-lib/Ouroboros/Network/Mock/ConcreteBlock.hs diff --git a/ouroboros-network/api/tests/Main.hs b/ouroboros-network/api/tests/Main.hs index 9a41659f17e..4b2eeeae647 100644 --- a/ouroboros-network/api/tests/Main.hs +++ b/ouroboros-network/api/tests/Main.hs @@ -3,8 +3,11 @@ module Main (main) where import Main.Utf8 (withUtf8) import Test.Tasty +import Test.Cardano.Network.Version qualified as Version import Test.Cardano.Network.NodeToClient.Version qualified as NodeToClient.Version import Test.Cardano.Network.NodeToNode.Version qualified as NodeToNode.Version +import Test.Ouroboros.Network.AnchoredFragment qualified as AnchoredFragment +import Test.Ouroboros.Network.Chain qualified as Chain import Test.Ouroboros.Network.PeerSelection.RelayAccessPoint qualified as RelayAccessPoint main :: IO () @@ -13,7 +16,10 @@ main = withUtf8 $ defaultMain tests tests :: TestTree tests = testGroup "ouroboros-network-api" - [ NodeToClient.Version.tests + [ AnchoredFragment.tests + , Chain.tests + , Version.tests + , NodeToClient.Version.tests , NodeToNode.Version.tests , RelayAccessPoint.tests ] diff --git a/ouroboros-network/tests/lib/Test/Cardano/Network/Version.hs b/ouroboros-network/api/tests/Test/Cardano/Network/Version.hs similarity index 92% rename from ouroboros-network/tests/lib/Test/Cardano/Network/Version.hs rename to ouroboros-network/api/tests/Test/Cardano/Network/Version.hs index 034f545804f..aeac2b2a8e1 100644 --- a/ouroboros-network/tests/lib/Test/Cardano/Network/Version.hs +++ b/ouroboros-network/api/tests/Test/Cardano/Network/Version.hs @@ -4,9 +4,9 @@ -- module Test.Cardano.Network.Version (tests) where -import Cardano.Network.NodeToClient (NodeToClientVersion (..), +import Cardano.Network.NodeToClient.Version (NodeToClientVersion (..), nodeToClientVersionCodec) -import Cardano.Network.NodeToNode (NodeToNodeVersion (..), +import Cardano.Network.NodeToNode.Version (NodeToNodeVersion (..), nodeToNodeVersionCodec) import Ouroboros.Network.CodecCBORTerm @@ -56,8 +56,8 @@ roundTripPropAll , Enum a , Bounded a , Show a - , Eq failure , Show failure + , Eq failure ) => CodecCBORTerm failure a -> Assertion roundTripPropAll codec = @@ -68,8 +68,6 @@ crossFailureProp :: forall failure a b. ( Show a , Show b - , Eq failure - , Show failure ) => CodecCBORTerm failure a -> CodecCBORTerm failure b @@ -85,8 +83,6 @@ crossFailurePropAll :: forall failure a b. ( Show a , Show b - , Eq failure - , Show failure ) => CodecCBORTerm failure a -> CodecCBORTerm failure b diff --git a/ouroboros-network/protocols/tests/Test/AnchoredFragment.hs b/ouroboros-network/api/tests/Test/Ouroboros/Network/AnchoredFragment.hs similarity index 99% rename from ouroboros-network/protocols/tests/Test/AnchoredFragment.hs rename to ouroboros-network/api/tests/Test/Ouroboros/Network/AnchoredFragment.hs index 40b0e2e2cf9..3480557a8b1 100644 --- a/ouroboros-network/protocols/tests/Test/AnchoredFragment.hs +++ b/ouroboros-network/api/tests/Test/Ouroboros/Network/AnchoredFragment.hs @@ -10,7 +10,7 @@ {-# OPTIONS_GHC -Wno-x-partial #-} #endif -module Test.AnchoredFragment +module Test.Ouroboros.Network.AnchoredFragment ( tests , TestBlockAnchoredFragment (..) ) where @@ -29,10 +29,11 @@ import Ouroboros.Network.AnchoredFragment (AnchoredFragment, import Ouroboros.Network.AnchoredFragment qualified as AF import Ouroboros.Network.Block import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators (TestBlockChain (..), + TestChainAndRange (..), addSlotGap, genChainAnchor, genNonNegative, + genSlotGap) import Ouroboros.Network.Mock.ConcreteBlock import Ouroboros.Network.Point (WithOrigin (..), withOrigin) -import Test.ChainGenerators (TestBlockChain (..), TestChainAndRange (..), - addSlotGap, genChainAnchor, genNonNegative, genSlotGap) -- diff --git a/ouroboros-network/protocols/tests/Test/Chain.hs b/ouroboros-network/api/tests/Test/Ouroboros/Network/Chain.hs similarity index 97% rename from ouroboros-network/protocols/tests/Test/Chain.hs rename to ouroboros-network/api/tests/Test/Ouroboros/Network/Chain.hs index e1ee4baecdc..79ec206cc7b 100644 --- a/ouroboros-network/protocols/tests/Test/Chain.hs +++ b/ouroboros-network/api/tests/Test/Ouroboros/Network/Chain.hs @@ -6,7 +6,7 @@ {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -module Test.Chain (tests) where +module Test.Ouroboros.Network.Chain (tests) where import Data.List qualified as L import Data.Maybe (listToMaybe) @@ -18,8 +18,8 @@ import Test.Tasty.QuickCheck (testProperty) import Ouroboros.Network.Block (blockPrevHash, pattern GenesisPoint, pointHash) import Ouroboros.Network.Mock.Chain (Chain (..)) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators hiding (tests) -import Test.ChainGenerators hiding (tests) import Test.Ouroboros.Network.Serialise (prop_serialise) diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 8f63260a3f3..e83e856363d 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -125,14 +125,37 @@ library api text >=1.2 && <2.2, typed-protocols ^>=1.1, +library api-tests-lib + import: ghc-options + hs-source-dirs: api/tests-lib + exposed-modules: + Ouroboros.Network.Mock.ConcreteBlock + Ouroboros.Network.Mock.Chain + Ouroboros.Network.Mock.ChainGenerators + build-depends: + QuickCheck, + base, + bytestring, + cardano-slotting:testlib ^>=0.2.0, + cborg, + hashable, + nothunks, + ouroboros-network:api, + quickcheck-instances, + serialise, + tasty, + tasty-quickcheck, + time, + test-suite api-tests import: ghc-options type: exitcode-stdio-1.0 main-is: Main.hs hs-source-dirs: api/tests - default-language: Haskell2010 - default-extensions: ImportQualifiedPost other-modules: + Test.Ouroboros.Network.AnchoredFragment + Test.Ouroboros.Network.Chain + Test.Cardano.Network.Version Test.Cardano.Network.NodeToClient.Version Test.Cardano.Network.NodeToNode.Version Test.Ouroboros.Network.PeerSelection.RelayAccessPoint @@ -145,8 +168,9 @@ test-suite api-tests cardano-binary, cborg, iproute, - ouroboros-network:api, + ouroboros-network:{api, api-tests-lib, tests-lib}, tasty, + tasty-hunit, tasty-quickcheck, with-utf8, @@ -833,7 +857,6 @@ library protocols-tests-lib Ouroboros.Network.Protocol.TxSubmission2.Direct Ouroboros.Network.Protocol.TxSubmission2.Examples Ouroboros.Network.Protocol.TxSubmission2.Test - Test.ChainGenerators Test.ChainProducerState Test.Data.CDDL Test.Data.PipeliningDepth @@ -843,7 +866,6 @@ library protocols-tests-lib QuickCheck, base >=4.14 && <4.22, bytestring, - cardano-slotting:testlib ^>=0.2.0, cardano-strict-containers, cborg, containers, @@ -853,7 +875,7 @@ library protocols-tests-lib io-sim, network, network-mux, - ouroboros-network:{api, framework, mock, protocols, tests-lib}, + ouroboros-network:{api, api-tests-lib, framework, mock, protocols, tests-lib}, pipes, quickcheck-instances, serialise, @@ -867,17 +889,11 @@ test-suite protocols-tests type: exitcode-stdio-1.0 hs-source-dirs: protocols/tests main-is: Main.hs - -- TODO: these two tests should be moved to `ouroboros-network:mock` - other-modules: - Test.AnchoredFragment - Test.Chain build-depends: - QuickCheck ^>=2.16, base >=4.14 && <4.22, - ouroboros-network:{api, mock, protocols-tests-lib, tests-lib}, + ouroboros-network:{protocols-tests-lib}, tasty, - tasty-quickcheck, ghc-options: -threaded @@ -906,7 +922,7 @@ test-suite protocols-cddl filepath, mtl, network, - ouroboros-network:{api, framework, mock, protocols, protocols-tests-lib}, + ouroboros-network:{api, api-tests-lib, framework, protocols, protocols-tests-lib}, process-extras, quickcheck-instances, serialise, @@ -916,6 +932,7 @@ test-suite protocols-cddl temporary, text, typed-protocols:{typed-protocols, stateful}, + tasty-quickcheck, ghc-options: -threaded @@ -955,20 +972,12 @@ library mock visibility: public hs-source-dirs: mock exposed-modules: - Ouroboros.Network.Mock.Chain - Ouroboros.Network.Mock.ConcreteBlock Ouroboros.Network.Mock.ProducerState build-depends: base >=4.14 && <4.22, - bytestring, - cborg, containers, - hashable, - nothunks, - ouroboros-network:api, - serialise, - time, + ouroboros-network:{api, api-tests-lib}, -- Simulation Test Library library ouroboros-network-tests-lib @@ -997,7 +1006,7 @@ library ouroboros-network-tests-lib network, network-mux, nothunks, - ouroboros-network:{ouroboros-network, api, cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, protocols, protocols-tests-lib, tests-lib}, + ouroboros-network:{ouroboros-network, api, api-tests-lib, cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, protocols, protocols-tests-lib, tests-lib}, pipes, pretty-simple, psqueues, @@ -1015,7 +1024,6 @@ library ouroboros-network-tests-lib Ouroboros.Network.BlockFetch.Examples Ouroboros.Network.MockNode Test.Cardano.Network.OrphanInstances.Tests - Test.Cardano.Network.Version Test.Ouroboros.Network.BlockFetch Test.Ouroboros.Network.Diffusion.Node Test.Ouroboros.Network.Diffusion.Node.ChainDB @@ -1092,7 +1100,7 @@ test-suite ouroboros-network-io-tests monoidal-synchronisation, network, network-mux, - ouroboros-network:{api, cardano-diffusion, framework, mock, protocols, protocols-tests-lib, tests-lib}, + ouroboros-network:{api, api-tests-lib, cardano-diffusion, framework, mock, protocols, protocols-tests-lib, tests-lib}, serialise, tasty, tasty-quickcheck, @@ -1127,7 +1135,7 @@ executable demo-chain-sync io-classes:{si-timers, strict-stm}, network-mux, optparse-applicative, - ouroboros-network:{ouroboros-network, api, cardano-diffusion, framework, mock, protocols}, + ouroboros-network:{ouroboros-network, api, api-tests-lib, cardano-diffusion, framework, protocols}, random, serialise, typed-protocols, diff --git a/ouroboros-network/protocols/cddl/Main.hs b/ouroboros-network/protocols/cddl/Main.hs index 0db8dc9f6f6..2a1b331fecd 100644 --- a/ouroboros-network/protocols/cddl/Main.hs +++ b/ouroboros-network/protocols/cddl/Main.hs @@ -59,7 +59,6 @@ import Ouroboros.Network.Block (Point, SlotNo, Tip, decodeTip, encodeTip, unwrapCBORinCBOR, wrapCBORinCBOR) import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Magic -import Ouroboros.Network.Mock.ConcreteBlock qualified as Concrete (Block) import Cardano.Network.NodeToClient.Version (NodeToClientVersion, NodeToClientVersionData (..), nodeToClientCodecCBORTerm) @@ -113,7 +112,8 @@ import Ouroboros.Network.Protocol.PeerSharing.Codec (codecPeerSharing) import Ouroboros.Network.Protocol.PeerSharing.Test () import Ouroboros.Network.Protocol.PeerSharing.Type qualified as PeerSharing -import Test.ChainGenerators () +import Ouroboros.Network.Mock.ChainGenerators () +import Ouroboros.Network.Mock.ConcreteBlock qualified as Concrete (Block) import Test.Data.CDDL (Any (..)) import Ouroboros.Network.PeerSelection.PeerSharing.Codec (decodeRemoteAddress, diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Test.hs index b5046fafec2..4a59c29f9ce 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/BlockFetch/Test.hs @@ -35,6 +35,7 @@ import Ouroboros.Network.Block (Serialised (..), genesisPoint, unwrapCBORinCBOR, import Ouroboros.Network.Mock.Chain (Chain, Point) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators (TestChainAndPoints (..)) import Ouroboros.Network.Mock.ConcreteBlock (Block) import Ouroboros.Network.Protocol.BlockFetch.Client @@ -45,7 +46,6 @@ import Ouroboros.Network.Protocol.BlockFetch.Server import Ouroboros.Network.Protocol.BlockFetch.Type import Test.Data.PipeliningDepth (PipeliningDepth (..)) -import Test.ChainGenerators (TestChainAndPoints (..)) import Test.Ouroboros.Network.Protocol.Utils (prop_codec_cborM, prop_codec_valid_cbor_encoding, splits2, splits3) diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Test.hs index 8471a58ce09..4a0c128b0f7 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/ChainSync/Test.hs @@ -36,6 +36,7 @@ import Ouroboros.Network.Block (BlockNo, Serialised (..), StandardHash, pattern GenesisPoint, unwrapCBORinCBOR, wrapCBORinCBOR) import Ouroboros.Network.Mock.Chain (Chain, Point) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators () import Ouroboros.Network.Mock.ConcreteBlock (Block, BlockHeader (..)) import Ouroboros.Network.Mock.ProducerState qualified as ChainProducerState @@ -50,11 +51,10 @@ import Ouroboros.Network.Protocol.ChainSync.ExamplesPipelined qualified as Chain import Ouroboros.Network.Protocol.ChainSync.Server import Ouroboros.Network.Protocol.ChainSync.Type +import Test.ChainProducerState (ChainProducerStateForkTest (..)) import Test.Data.PipeliningDepth (PipeliningDepth (..)) import Test.Ouroboros.Network.Utils (renderRanges) -import Test.ChainGenerators () -import Test.ChainProducerState (ChainProducerStateForkTest (..)) import Test.Ouroboros.Network.Protocol.Utils (prop_codec_cborM, prop_codec_valid_cbor_encoding, splits2, splits3) diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs index 108a3c455fb..94eff2e652a 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs @@ -41,6 +41,7 @@ import Ouroboros.Network.Channel import Ouroboros.Network.Driver.Stateful qualified as Stateful import Ouroboros.Network.Util.ShowProxy +import Ouroboros.Network.Mock.ChainGenerators () import Ouroboros.Network.Mock.Chain (Point) import Ouroboros.Network.Mock.ConcreteBlock (Block) @@ -51,7 +52,6 @@ import Ouroboros.Network.Protocol.LocalStateQuery.Examples import Ouroboros.Network.Protocol.LocalStateQuery.Server import Ouroboros.Network.Protocol.LocalStateQuery.Type -import Test.ChainGenerators () import Test.Ouroboros.Network.Protocol.Utils import Test.QuickCheck as QC hiding (Result, Some (Some)) diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs index 85c96f7cf68..b644266956b 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Test.hs @@ -12,6 +12,7 @@ module Ouroboros.Network.Protocol.LocalTxMonitor.Test (tests) where import Codec.Serialise (Serialise) import Codec.Serialise qualified as S import Data.ByteString.Lazy (ByteString) +import Data.Text qualified as Text import Control.Monad.Class.MonadAsync import Control.Monad.Class.MonadST @@ -36,8 +37,8 @@ import Ouroboros.Network.Protocol.LocalTxMonitor.Examples import Ouroboros.Network.Protocol.LocalTxMonitor.Server import Ouroboros.Network.Protocol.LocalTxMonitor.Type -import Data.Text qualified as Text -import Test.ChainGenerators () +import Ouroboros.Network.Mock.ChainGenerators () + import Test.Ouroboros.Network.Protocol.Utils (prop_codec_cborM, prop_codec_valid_cbor_encoding, splits2, splits3) import Test.QuickCheck hiding (Result) diff --git a/ouroboros-network/protocols/tests-lib/Test/ChainProducerState.hs b/ouroboros-network/protocols/tests-lib/Test/ChainProducerState.hs index 814d4859bcd..7c8a64a0abe 100644 --- a/ouroboros-network/protocols/tests-lib/Test/ChainProducerState.hs +++ b/ouroboros-network/protocols/tests-lib/Test/ChainProducerState.hs @@ -22,12 +22,11 @@ import Ouroboros.Network.Block (HasHeader, genesisPoint, pointSlot) import Ouroboros.Network.Mock.Chain (Chain, ChainUpdate (..), Point (..), headPoint, pointOnChain) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators (TestBlockChain (..), + TestBlockChainAndUpdates (..), TestChainFork (..), mkRollbackPoint) import Ouroboros.Network.Mock.ConcreteBlock (Block) import Ouroboros.Network.Mock.ProducerState -import Test.ChainGenerators (TestBlockChain (..), TestBlockChainAndUpdates (..), - TestChainFork (..), mkRollbackPoint) - tests :: TestTree tests = testGroup "ChainProducerState" diff --git a/ouroboros-network/protocols/tests/Main.hs b/ouroboros-network/protocols/tests/Main.hs index 78f8f760245..3e1a90d9a95 100644 --- a/ouroboros-network/protocols/tests/Main.hs +++ b/ouroboros-network/protocols/tests/Main.hs @@ -11,9 +11,6 @@ import Ouroboros.Network.Protocol.LocalTxMonitor.Test qualified (tests) import Ouroboros.Network.Protocol.LocalTxSubmission.Test qualified (tests) import Ouroboros.Network.Protocol.PeerSharing.Test qualified (tests) import Ouroboros.Network.Protocol.TxSubmission2.Test qualified (tests) -import Test.AnchoredFragment qualified (tests) -import Test.Chain qualified (tests) -import Test.ChainGenerators qualified (tests) import Test.Data.CDDL qualified (tests) main :: IO () @@ -24,11 +21,7 @@ tests = testGroup "ouroboros-network-protocols" -- data structures - [ Test.AnchoredFragment.tests - , Test.Chain.tests - , Test.ChainGenerators.tests - - , Test.Data.CDDL.tests + [ Test.Data.CDDL.tests -- protocols , Ouroboros.Network.Protocol.ChainSync.Test.tests diff --git a/ouroboros-network/tests/io/Test/Ouroboros/Network/Pipe.hs b/ouroboros-network/tests/io/Test/Ouroboros/Network/Pipe.hs index 18649fef237..5c7064e4a61 100644 --- a/ouroboros-network/tests/io/Test/Ouroboros/Network/Pipe.hs +++ b/ouroboros-network/tests/io/Test/Ouroboros/Network/Pipe.hs @@ -21,7 +21,6 @@ import Control.Monad.Class.MonadTimer.SI import Data.ByteString.Lazy qualified as BL import Data.Monoid.Synchronisation import Data.Void (Void) -import Test.ChainGenerators (TestBlockChainAndUpdates (..)) import Test.QuickCheck import Test.Tasty (TestTree, testGroup) import Test.Tasty.QuickCheck (testProperty) @@ -49,6 +48,7 @@ import Ouroboros.Network.Block (decodeTip, encodeTip) import Ouroboros.Network.Context import Ouroboros.Network.Mock.Chain (Chain, ChainUpdate, Point) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators (TestBlockChainAndUpdates (..)) import Ouroboros.Network.Mock.ProducerState qualified as CPS import Ouroboros.Network.Protocol.ChainSync.Client as ChainSync import Ouroboros.Network.Protocol.ChainSync.Codec as ChainSync diff --git a/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs b/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs index f7d222ce976..5655dca151a 100644 --- a/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs +++ b/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs @@ -38,6 +38,7 @@ import Ouroboros.Network.IOManager import Ouroboros.Network.Magic import Ouroboros.Network.Mock.Chain (Chain, ChainUpdate, Point) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators (TestBlockChainAndUpdates (..)) import Ouroboros.Network.Mock.ProducerState qualified as CPS import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Ouroboros.Network.Protocol.ChainSync.Client qualified as ChainSync @@ -52,7 +53,6 @@ import Ouroboros.Network.Protocol.Handshake.Version (acceptableVersion, import Ouroboros.Network.Server.Simple qualified as Server.Simple import Ouroboros.Network.Util.ShowProxy -import Test.ChainGenerators (TestBlockChainAndUpdates (..)) import Test.Ouroboros.Network.Serialise import Test.QuickCheck diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs index 9dbaa40bf28..18c5c67ad6c 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs @@ -12,7 +12,6 @@ module Test.Ouroboros.Network.BlockFetch , tests ) where -import Test.ChainGenerators (TestChainFork (..)) import Test.QuickCheck import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit @@ -52,6 +51,7 @@ import Ouroboros.Network.BlockFetch.DeltaQ import Ouroboros.Network.BlockFetch.Examples import Ouroboros.Network.Driver (TraceSendRecv) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators (TestChainFork (..)) import Ouroboros.Network.Mock.ConcreteBlock import Ouroboros.Network.Protocol.BlockFetch.Type (BlockFetch) diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/MockNode.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/MockNode.hs index 390a70780eb..b9e2fdecf92 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/MockNode.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/MockNode.hs @@ -40,12 +40,12 @@ import Control.Monad.IOSim qualified as Sim import Ouroboros.Network.Block import Ouroboros.Network.Mock.Chain (Chain (..)) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators (TestBlockChain (..)) import Ouroboros.Network.Mock.ConcreteBlock as ConcreteBlock import Ouroboros.Network.Mock.ProducerState (ChainProducerState (..)) import Ouroboros.Network.MockNode -import Test.ChainGenerators (TestBlockChain (..)) tests :: TestTree diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Mux.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Mux.hs index f92153e2dd0..aabe44f79a3 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Mux.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Mux.hs @@ -25,7 +25,6 @@ import Control.Monad.Class.MonadTimer.SI import Control.Monad.IOSim import Control.Tracer -import Test.ChainGenerators (TestBlockChainAndUpdates (..)) import Test.QuickCheck import Test.Tasty (TestTree, testGroup) import Test.Tasty.QuickCheck (testProperty) @@ -38,6 +37,7 @@ import Ouroboros.Network.Block (Tip (..), decodeTip, encodeTip) import Ouroboros.Network.Context import Ouroboros.Network.Mock.Chain (Chain, ChainUpdate, Point) import Ouroboros.Network.Mock.Chain qualified as Chain +import Ouroboros.Network.Mock.ChainGenerators (TestBlockChainAndUpdates (..)) import Ouroboros.Network.Mock.ProducerState qualified as CPS import Ouroboros.Network.Protocol.ChainSync.Client qualified as ChainSync import Ouroboros.Network.Protocol.ChainSync.Codec qualified as ChainSync diff --git a/ouroboros-network/tests/sim/Main.hs b/ouroboros-network/tests/sim/Main.hs index 68592cbf9e6..5340b349851 100644 --- a/ouroboros-network/tests/sim/Main.hs +++ b/ouroboros-network/tests/sim/Main.hs @@ -4,7 +4,6 @@ import Main.Utf8 (withUtf8) import Test.Tasty import Test.Cardano.Network.OrphanInstances.Tests qualified (tests) -import Test.Cardano.Network.Version qualified (tests) import Test.ChainProducerState qualified (tests) @@ -35,7 +34,6 @@ tests = -- cardano , Test.Cardano.Network.OrphanInstances.Tests.tests - , Test.Cardano.Network.Version.tests -- network logic , Test.Ouroboros.Network.Diffusion.Policies.tests @@ -55,7 +53,6 @@ tests = , Test.Ouroboros.Network.PeerSelection.Cardano.MockEnvironment.tests , Test.Ouroboros.Network.PeerSelection.Cardano.PublicRootPeers.tests - -- pseudo system-level , Test.Ouroboros.Network.MockNode.tests ] From 691115aaf6d822d2ed487c16b3ab2ff7abbd798f Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 16 Sep 2025 15:47:17 +0200 Subject: [PATCH 11/24] ouroboros-network:mock - moved its last module to protocols-tests-lib --- ouroboros-network/ouroboros-network.cabal | 32 ++++++------------- .../Ouroboros/Network/Mock/ProducerState.hs | 0 2 files changed, 10 insertions(+), 22 deletions(-) rename ouroboros-network/{mock => protocols/tests-lib}/Ouroboros/Network/Mock/ProducerState.hs (100%) diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index e83e856363d..4c5efed6e04 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -129,9 +129,10 @@ library api-tests-lib import: ghc-options hs-source-dirs: api/tests-lib exposed-modules: - Ouroboros.Network.Mock.ConcreteBlock Ouroboros.Network.Mock.Chain Ouroboros.Network.Mock.ChainGenerators + Ouroboros.Network.Mock.ConcreteBlock + build-depends: QuickCheck, base, @@ -153,11 +154,11 @@ test-suite api-tests main-is: Main.hs hs-source-dirs: api/tests other-modules: - Test.Ouroboros.Network.AnchoredFragment - Test.Ouroboros.Network.Chain - Test.Cardano.Network.Version Test.Cardano.Network.NodeToClient.Version Test.Cardano.Network.NodeToNode.Version + Test.Cardano.Network.Version + Test.Ouroboros.Network.AnchoredFragment + Test.Ouroboros.Network.Chain Test.Ouroboros.Network.PeerSelection.RelayAccessPoint build-depends: @@ -822,6 +823,7 @@ library protocols-tests-lib visibility: public hs-source-dirs: protocols/tests-lib exposed-modules: + Ouroboros.Network.Mock.ProducerState Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL Ouroboros.Network.Protocol.BlockFetch.Direct Ouroboros.Network.Protocol.BlockFetch.Examples @@ -875,7 +877,7 @@ library protocols-tests-lib io-sim, network, network-mux, - ouroboros-network:{api, api-tests-lib, framework, mock, protocols, tests-lib}, + ouroboros-network:{api, api-tests-lib, framework, protocols, tests-lib}, pipes, quickcheck-instances, serialise, @@ -889,10 +891,9 @@ test-suite protocols-tests type: exitcode-stdio-1.0 hs-source-dirs: protocols/tests main-is: Main.hs - build-depends: base >=4.14 && <4.22, - ouroboros-network:{protocols-tests-lib}, + ouroboros-network:protocols-tests-lib, tasty, ghc-options: @@ -932,7 +933,6 @@ test-suite protocols-cddl temporary, text, typed-protocols:{typed-protocols, stateful}, - tasty-quickcheck, ghc-options: -threaded @@ -967,18 +967,6 @@ test-suite protocols-bench if impl(ghc >=8.6) ghc-options: -fproc-alignment=64 -library mock - import: ghc-options - visibility: public - hs-source-dirs: mock - exposed-modules: - Ouroboros.Network.Mock.ProducerState - - build-depends: - base >=4.14 && <4.22, - containers, - ouroboros-network:{api, api-tests-lib}, - -- Simulation Test Library library ouroboros-network-tests-lib import: ghc-options-tests @@ -1006,7 +994,7 @@ library ouroboros-network-tests-lib network, network-mux, nothunks, - ouroboros-network:{ouroboros-network, api, api-tests-lib, cardano-diffusion, framework, framework-tests-lib, mock, orphan-instances, protocols, protocols-tests-lib, tests-lib}, + ouroboros-network:{ouroboros-network, api, api-tests-lib, cardano-diffusion, framework, framework-tests-lib, orphan-instances, protocols, protocols-tests-lib, tests-lib}, pipes, pretty-simple, psqueues, @@ -1100,7 +1088,7 @@ test-suite ouroboros-network-io-tests monoidal-synchronisation, network, network-mux, - ouroboros-network:{api, api-tests-lib, cardano-diffusion, framework, mock, protocols, protocols-tests-lib, tests-lib}, + ouroboros-network:{api, api-tests-lib, cardano-diffusion, framework, protocols, protocols-tests-lib, tests-lib}, serialise, tasty, tasty-quickcheck, diff --git a/ouroboros-network/mock/Ouroboros/Network/Mock/ProducerState.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Mock/ProducerState.hs similarity index 100% rename from ouroboros-network/mock/Ouroboros/Network/Mock/ProducerState.hs rename to ouroboros-network/protocols/tests-lib/Ouroboros/Network/Mock/ProducerState.hs From dce4f9d0e9442ab860ec8f9995c3625cdcc77f34 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 17 Sep 2025 15:24:11 +0200 Subject: [PATCH 12/24] cardano-diffusion package Introduced `cardano-diffusion` package. Some things are hidden inside of it because that's how we are testing things now, in particular `PeerSelection` and `Testnet` tests depend on `Cardano` constructs. In the future we could split them into general test & cardano specific tests, this will be in particularly useful for another non-trivial extension of `ouroboros-network`, but also might organise tests better. --- cabal.project | 1 + cardano-client/cardano-client.cabal | 3 +- cardano-diffusion/CHANGELOG.md | 5 + cardano-diffusion/LICENSE | 177 ++++++ cardano-diffusion/NOTICE | 14 + .../api/lib/Cardano/Network/ConsensusMode.hs | 0 .../api/lib/Cardano/Network/FetchMode.hs | 31 + .../Cardano/Network/NodeToClient/Version.hs | 0 .../lib/Cardano/Network/NodeToNode/Version.hs | 0 .../Network/PeerSelection/Bootstrap.hs | 0 .../Network/PeerSelection/LocalRootPeers.hs | 0 .../Network/PeerSelection/PeerTrustable.hs | 0 .../api/lib/Cardano/Network/Types.hs | 0 cardano-diffusion/api/tests/Main.hs | 21 + .../Cardano/Network/NodeToClient/Version.hs | 0 .../Cardano/Network/NodeToNode/Version.hs | 0 .../api/tests/Test/Cardano/Network/Version.hs | 0 cardano-diffusion/cardano-diffusion.cabal | 495 ++++++++++++++++ .../20250922_173749_coot_packages.md | 12 + cardano-diffusion/changelog.d/scriv.ini | 14 + .../demo/chain-sync.hs | 0 .../lib}/Cardano/Network/Diffusion.hs | 0 .../Network/Diffusion/Configuration.hs | 9 + .../Cardano/Network/Diffusion/Handlers.hs | 4 +- .../Cardano/Network/Diffusion/Policies.hs | 0 .../Cardano/Network/Diffusion/Topology.hs | 0 .../lib}/Cardano/Network/Diffusion/Types.hs | 3 +- .../Network/LedgerPeerConsensusInterface.hs | 0 .../lib}/Cardano/Network/NodeToClient.hs | 10 +- .../lib}/Cardano/Network/NodeToNode.hs | 4 +- .../Cardano/Network/PeerSelection/Churn.hs | 2 + .../Network/PeerSelection/ExtraRootPeers.hs | 0 .../Network/PeerSelection/Governor/Monitor.hs | 35 +- .../Governor/PeerSelectionActions.hs | 0 .../Governor/PeerSelectionState.hs | 0 .../Network/PeerSelection/Governor/Types.hs | 43 +- .../PeerSelection/PeerSelectionActions.hs | 0 .../Network/PeerSelection/PublicRootPeers.hs | 0 .../PeerSelection/State/LocalRootPeers.hs | 62 ++ .../Cardano/Network/OrphanInstances.hs | 11 + .../protocols/bench/Main.hs | 58 +- .../protocols/cddl/Main.hs | 99 ++-- .../protocols/cddl/specs/block-fetch.cddl | 0 .../protocols/cddl/specs/chain-sync.cddl | 0 .../cddl/specs/handshake-node-to-client.cddl | 0 .../specs/handshake-node-to-node-v14.cddl | 0 .../protocols/cddl/specs/keep-alive.cddl | 0 .../cddl/specs/local-state-query.cddl | 0 .../cddl/specs/local-tx-monitor.cddl | 0 .../cddl/specs/local-tx-submission.cddl | 0 .../protocols/cddl/specs/network.base.cddl | 0 .../specs/node-to-node-version-data-v14.cddl | 0 .../handshake-node-to-node-v11-12.cddl | 0 .../obsolete/handshake-node-to-node-v13.cddl | 0 .../obsolete/handshake-node-to-node.cddl | 0 .../node-to-node-version-data-v11-12.cddl | 0 .../node-to-node-version-data-v13.cddl | 0 .../obsolete/node-to-node-version-data.cddl | 0 .../specs/obsolete/peer-sharing-v11-12.cddl | 0 .../cddl/specs/obsolete/peer-sharing-v13.cddl | 0 .../cddl/specs/peer-sharing-v14.cddl | 0 .../protocols/cddl/specs/tx-submission2.cddl | 0 .../Network/Protocol/Handshake/Codec.hs | 37 ++ .../Network/Protocol/LocalStateQuery/Codec.hs | 49 ++ .../Network/Protocol/LocalTxMonitor/Codec.hs | 48 ++ .../Network/Protocol/PeerSharing/Codec.hs | 26 + .../Network/Protocol/Handshake/Test.hs | 535 ++++++++++++++++++ .../Protocol/PeerSharing/Codec/CDDL.hs | 2 +- cardano-diffusion/protocols/tests/Main.hs | 16 + .../Cardano}/Network/Diffusion/Policies.hs | 2 +- .../Test/Cardano/Network/Diffusion/Testnet.hs | 64 ++- .../Diffusion/Testnet}/MiniProtocols.hs | 3 +- .../Network/Diffusion/Testnet}/Simulation.hs | 74 ++- .../Cardano/Network/OrphanInstances/Tests.hs | 5 +- .../Test/Cardano}/Network/PeerSelection.hs | 117 +++- .../Cardano}/Network/PeerSelection/Gource.hs | 12 +- .../Network/PeerSelection}/Instances.hs | 2 +- .../Network/PeerSelection}/LocalRootPeers.hs | 14 +- .../Network/PeerSelection}/MockEnvironment.hs | 49 +- .../Network/PeerSelection}/PublicRootPeers.hs | 2 +- .../Cardano}/Network/PeerSelection/Utils.hs | 43 +- cardano-diffusion/tests/sim/Main.hs | 30 + dmq-node/src/DMQ/Diffusion/Arguments.hs | 3 +- dmq-node/src/DMQ/Tracer.hs | 6 + .../Network/BlockFetch/ConsensusInterface.hs | 22 - ouroboros-network/api/tests/Main.hs | 8 +- .../Network/Protocol/Handshake/Codec.hs | 24 - .../lib/Ouroboros/Network/Diffusion.hs | 11 +- .../Network/Diffusion/Configuration.hs | 12 - .../lib/Ouroboros/Network/Diffusion/Types.hs | 15 +- .../Ouroboros/Network/PeerSelection/Churn.hs | 8 +- .../Network/PeerSelection/Governor.hs | 53 +- .../PeerSelection/Governor/ActivePeers.hs | 46 +- .../PeerSelection/Governor/BigLedgerPeers.hs | 15 +- .../Governor/EstablishedPeers.hs | 37 +- .../PeerSelection/Governor/KnownPeers.hs | 14 +- .../Network/PeerSelection/Governor/Monitor.hs | 21 +- .../PeerSelection/Governor/RootPeers.hs | 10 +- .../Network/PeerSelection/Governor/Types.hs | 123 ++-- .../PeerSelection/State/LocalRootPeers.hs | 51 -- .../Network/TxSubmission/Inbound/V1.hs | 6 +- .../TxSubmission/Inbound/V2/Registry.hs | 2 +- .../Ouroboros/Network/OrphanInstances.hs | 16 +- ouroboros-network/ouroboros-network.cabal | 202 +------ .../Network/Protocol/LocalStateQuery/Codec.hs | 8 +- .../Network/Protocol/LocalStateQuery/Type.hs | 4 + .../Network/Protocol/LocalTxMonitor/Codec.hs | 8 +- .../Network/Protocol/LocalTxMonitor/Type.hs | 5 + .../Network/Protocol/Handshake/Test.hs | 481 ---------------- .../Network/Protocol/LocalStateQuery/Test.hs | 2 +- .../Protocol/LocalTxMonitor/Codec/CDDL.hs | 2 +- ouroboros-network/protocols/tests/Main.hs | 8 +- .../tests/io/Test/Ouroboros/Network/Socket.hs | 112 +++- .../Ouroboros/Network/BlockFetch/Examples.hs | 6 +- .../lib/Test/Ouroboros/Network/BlockFetch.hs | 5 +- .../Test/Ouroboros/Network/Diffusion/Node.hs | 71 +-- .../Network/Diffusion/Node/Kernel.hs | 2 - .../lib/Test/Ouroboros/Network/LedgerPeers.hs | 4 +- .../Network/PeerSelection/Instances.hs | 5 +- .../Ouroboros/Network/TxSubmission/AppV1.hs | 9 +- .../Ouroboros/Network/TxSubmission/AppV2.hs | 7 +- ouroboros-network/tests/sim/Main.hs | 21 +- 122 files changed, 2364 insertions(+), 1344 deletions(-) create mode 100644 cardano-diffusion/CHANGELOG.md create mode 100644 cardano-diffusion/LICENSE create mode 100644 cardano-diffusion/NOTICE rename {ouroboros-network => cardano-diffusion}/api/lib/Cardano/Network/ConsensusMode.hs (100%) create mode 100644 cardano-diffusion/api/lib/Cardano/Network/FetchMode.hs rename {ouroboros-network => cardano-diffusion}/api/lib/Cardano/Network/NodeToClient/Version.hs (100%) rename {ouroboros-network => cardano-diffusion}/api/lib/Cardano/Network/NodeToNode/Version.hs (100%) rename {ouroboros-network => cardano-diffusion}/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs (100%) rename {ouroboros-network => cardano-diffusion}/api/lib/Cardano/Network/PeerSelection/LocalRootPeers.hs (100%) rename {ouroboros-network => cardano-diffusion}/api/lib/Cardano/Network/PeerSelection/PeerTrustable.hs (100%) rename {ouroboros-network => cardano-diffusion}/api/lib/Cardano/Network/Types.hs (100%) create mode 100644 cardano-diffusion/api/tests/Main.hs rename {ouroboros-network => cardano-diffusion}/api/tests/Test/Cardano/Network/NodeToClient/Version.hs (100%) rename {ouroboros-network => cardano-diffusion}/api/tests/Test/Cardano/Network/NodeToNode/Version.hs (100%) rename {ouroboros-network => cardano-diffusion}/api/tests/Test/Cardano/Network/Version.hs (100%) create mode 100644 cardano-diffusion/cardano-diffusion.cabal create mode 100644 cardano-diffusion/changelog.d/20250922_173749_coot_packages.md create mode 100644 cardano-diffusion/changelog.d/scriv.ini rename {ouroboros-network => cardano-diffusion}/demo/chain-sync.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/Diffusion.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/Diffusion/Configuration.hs (90%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/Diffusion/Handlers.hs (95%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/Diffusion/Policies.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/Diffusion/Topology.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/Diffusion/Types.hs (98%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/LedgerPeerConsensusInterface.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/NodeToClient.hs (96%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/NodeToNode.hs (99%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/PeerSelection/Churn.hs (99%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/PeerSelection/ExtraRootPeers.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/PeerSelection/Governor/Monitor.hs (95%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/PeerSelection/Governor/PeerSelectionActions.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/PeerSelection/Governor/Types.hs (89%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/PeerSelection/PeerSelectionActions.hs (100%) rename {ouroboros-network/cardano-diffusion => cardano-diffusion/lib}/Cardano/Network/PeerSelection/PublicRootPeers.hs (100%) create mode 100644 cardano-diffusion/lib/Cardano/Network/PeerSelection/State/LocalRootPeers.hs rename {ouroboros-network => cardano-diffusion}/orphan-instances/Cardano/Network/OrphanInstances.hs (91%) rename {ouroboros-network => cardano-diffusion}/protocols/bench/Main.hs (92%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/Main.hs (91%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/block-fetch.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/chain-sync.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/handshake-node-to-client.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/handshake-node-to-node-v14.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/keep-alive.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/local-state-query.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/local-tx-monitor.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/local-tx-submission.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/network.base.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/node-to-node-version-data-v14.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/obsolete/handshake-node-to-node.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/obsolete/node-to-node-version-data.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/obsolete/peer-sharing-v13.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/peer-sharing-v14.cddl (100%) rename {ouroboros-network => cardano-diffusion}/protocols/cddl/specs/tx-submission2.cddl (100%) create mode 100644 cardano-diffusion/protocols/lib/Cardano/Network/Protocol/Handshake/Codec.hs create mode 100644 cardano-diffusion/protocols/lib/Cardano/Network/Protocol/LocalStateQuery/Codec.hs create mode 100644 cardano-diffusion/protocols/lib/Cardano/Network/Protocol/LocalTxMonitor/Codec.hs create mode 100644 cardano-diffusion/protocols/lib/Cardano/Network/Protocol/PeerSharing/Codec.hs create mode 100644 cardano-diffusion/protocols/tests-lib/Cardano/Network/Protocol/Handshake/Test.hs rename {ouroboros-network/protocols/tests-lib/Ouroboros => cardano-diffusion/protocols/tests-lib/Cardano}/Network/Protocol/PeerSharing/Codec/CDDL.hs (90%) create mode 100644 cardano-diffusion/protocols/tests/Main.hs rename {ouroboros-network/tests/lib/Test/Ouroboros => cardano-diffusion/tests/lib/Test/Cardano}/Network/Diffusion/Policies.hs (99%) rename ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs => cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs (98%) rename {ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node => cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet}/MiniProtocols.hs (99%) rename {ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano => cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet}/Simulation.hs (96%) rename {ouroboros-network => cardano-diffusion}/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs (93%) rename {ouroboros-network/tests/lib/Test/Ouroboros => cardano-diffusion/tests/lib/Test/Cardano}/Network/PeerSelection.hs (97%) rename {ouroboros-network/tests/lib/Test/Ouroboros => cardano-diffusion/tests/lib/Test/Cardano}/Network/PeerSelection/Gource.hs (93%) rename {ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano => cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection}/Instances.hs (95%) rename {ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano => cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection}/LocalRootPeers.hs (71%) rename {ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano => cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection}/MockEnvironment.hs (97%) rename {ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano => cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection}/PublicRootPeers.hs (99%) rename {ouroboros-network/tests/lib/Test/Ouroboros => cardano-diffusion/tests/lib/Test/Cardano}/Network/PeerSelection/Utils.hs (72%) create mode 100644 cardano-diffusion/tests/sim/Main.hs diff --git a/cabal.project b/cabal.project index 10ffab78a43..2fe9851d5dd 100644 --- a/cabal.project +++ b/cabal.project @@ -24,6 +24,7 @@ packages: ./cardano-ping ./monoidal-synchronisation ./network-mux ./ouroboros-network + ./cardano-diffusion ./ntp-client ./cardano-client ./dmq-node diff --git a/cardano-client/cardano-client.cabal b/cardano-client/cardano-client.cabal index f2c8c861479..10cf8d4cf7f 100644 --- a/cardano-client/cardano-client.cabal +++ b/cardano-client/cardano-client.cabal @@ -23,12 +23,13 @@ library build-depends: base >=4.14 && <4.22, bytestring >=0.10 && <0.13, + cardano-diffusion ^>=0.1, cborg >=0.2.8 && <0.3, containers >=0.5 && <0.9, contra-tracer >=0.1 && <0.3, io-classes:si-timers ^>=1.8.0.1, network-mux ^>=0.9, - ouroboros-network:{api, cardano-diffusion, framework} ^>=0.23, + ouroboros-network:{api, framework} ^>=0.23, ghc-options: -Wall diff --git a/cardano-diffusion/CHANGELOG.md b/cardano-diffusion/CHANGELOG.md new file mode 100644 index 00000000000..a03992a2f7a --- /dev/null +++ b/cardano-diffusion/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for cardano-diffusion + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/cardano-diffusion/LICENSE b/cardano-diffusion/LICENSE new file mode 100644 index 00000000000..f433b1a53f5 --- /dev/null +++ b/cardano-diffusion/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/cardano-diffusion/NOTICE b/cardano-diffusion/NOTICE new file mode 100644 index 00000000000..3efdc24424e --- /dev/null +++ b/cardano-diffusion/NOTICE @@ -0,0 +1,14 @@ +Copyright 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/ouroboros-network/api/lib/Cardano/Network/ConsensusMode.hs b/cardano-diffusion/api/lib/Cardano/Network/ConsensusMode.hs similarity index 100% rename from ouroboros-network/api/lib/Cardano/Network/ConsensusMode.hs rename to cardano-diffusion/api/lib/Cardano/Network/ConsensusMode.hs diff --git a/cardano-diffusion/api/lib/Cardano/Network/FetchMode.hs b/cardano-diffusion/api/lib/Cardano/Network/FetchMode.hs new file mode 100644 index 00000000000..8747dbc94a1 --- /dev/null +++ b/cardano-diffusion/api/lib/Cardano/Network/FetchMode.hs @@ -0,0 +1,31 @@ +{-# LANGUAGE LambdaCase #-} + +module Cardano.Network.FetchMode + ( mkReadFetchMode + , module Ouroboros.Network.BlockFetch.ConsensusInterface + ) where + +import Data.Functor ((<&>)) + +import Cardano.Network.ConsensusMode (ConsensusMode (..)) +import Cardano.Network.Types (LedgerStateJudgement (..)) +import Ouroboros.Network.BlockFetch.ConsensusInterface + + +-- | Construct 'readFetchMode' for 'BlockFetchConsensusInterface' by branching +-- on the 'ConsensusMode'. +mkReadFetchMode + :: Functor m + => ConsensusMode + -> m LedgerStateJudgement + -- ^ Used for 'GenesisMode'. + -> m PraosFetchMode + -- ^ Used for 'PraosMode' for backwards compatibility. + -> m FetchMode +mkReadFetchMode consensusMode getLedgerStateJudgement getFetchMode = + case consensusMode of + GenesisMode -> getLedgerStateJudgement <&> \case + YoungEnough -> PraosFetchMode FetchModeDeadline + TooOld -> FetchModeGenesis + PraosMode -> PraosFetchMode <$> getFetchMode + diff --git a/ouroboros-network/api/lib/Cardano/Network/NodeToClient/Version.hs b/cardano-diffusion/api/lib/Cardano/Network/NodeToClient/Version.hs similarity index 100% rename from ouroboros-network/api/lib/Cardano/Network/NodeToClient/Version.hs rename to cardano-diffusion/api/lib/Cardano/Network/NodeToClient/Version.hs diff --git a/ouroboros-network/api/lib/Cardano/Network/NodeToNode/Version.hs b/cardano-diffusion/api/lib/Cardano/Network/NodeToNode/Version.hs similarity index 100% rename from ouroboros-network/api/lib/Cardano/Network/NodeToNode/Version.hs rename to cardano-diffusion/api/lib/Cardano/Network/NodeToNode/Version.hs diff --git a/ouroboros-network/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs b/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs similarity index 100% rename from ouroboros-network/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs rename to cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs diff --git a/ouroboros-network/api/lib/Cardano/Network/PeerSelection/LocalRootPeers.hs b/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/LocalRootPeers.hs similarity index 100% rename from ouroboros-network/api/lib/Cardano/Network/PeerSelection/LocalRootPeers.hs rename to cardano-diffusion/api/lib/Cardano/Network/PeerSelection/LocalRootPeers.hs diff --git a/ouroboros-network/api/lib/Cardano/Network/PeerSelection/PeerTrustable.hs b/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/PeerTrustable.hs similarity index 100% rename from ouroboros-network/api/lib/Cardano/Network/PeerSelection/PeerTrustable.hs rename to cardano-diffusion/api/lib/Cardano/Network/PeerSelection/PeerTrustable.hs diff --git a/ouroboros-network/api/lib/Cardano/Network/Types.hs b/cardano-diffusion/api/lib/Cardano/Network/Types.hs similarity index 100% rename from ouroboros-network/api/lib/Cardano/Network/Types.hs rename to cardano-diffusion/api/lib/Cardano/Network/Types.hs diff --git a/cardano-diffusion/api/tests/Main.hs b/cardano-diffusion/api/tests/Main.hs new file mode 100644 index 00000000000..fed47fc7f2a --- /dev/null +++ b/cardano-diffusion/api/tests/Main.hs @@ -0,0 +1,21 @@ +module Main (main) where + +import Main.Utf8 (withUtf8) +import Test.Tasty + +import Test.Cardano.Network.NodeToClient.Version qualified as NodeToClient.Version +import Test.Cardano.Network.NodeToNode.Version qualified as NodeToNode.Version +import Test.Cardano.Network.Version qualified as Version + +main :: IO () +main = withUtf8 $ defaultMain tests + +tests :: TestTree +tests = + testGroup "cardano-diffusion:api" + [ Version.tests + , NodeToClient.Version.tests + , NodeToNode.Version.tests + ] + + diff --git a/ouroboros-network/api/tests/Test/Cardano/Network/NodeToClient/Version.hs b/cardano-diffusion/api/tests/Test/Cardano/Network/NodeToClient/Version.hs similarity index 100% rename from ouroboros-network/api/tests/Test/Cardano/Network/NodeToClient/Version.hs rename to cardano-diffusion/api/tests/Test/Cardano/Network/NodeToClient/Version.hs diff --git a/ouroboros-network/api/tests/Test/Cardano/Network/NodeToNode/Version.hs b/cardano-diffusion/api/tests/Test/Cardano/Network/NodeToNode/Version.hs similarity index 100% rename from ouroboros-network/api/tests/Test/Cardano/Network/NodeToNode/Version.hs rename to cardano-diffusion/api/tests/Test/Cardano/Network/NodeToNode/Version.hs diff --git a/ouroboros-network/api/tests/Test/Cardano/Network/Version.hs b/cardano-diffusion/api/tests/Test/Cardano/Network/Version.hs similarity index 100% rename from ouroboros-network/api/tests/Test/Cardano/Network/Version.hs rename to cardano-diffusion/api/tests/Test/Cardano/Network/Version.hs diff --git a/cardano-diffusion/cardano-diffusion.cabal b/cardano-diffusion/cardano-diffusion.cabal new file mode 100644 index 00000000000..bdc606c4a09 --- /dev/null +++ b/cardano-diffusion/cardano-diffusion.cabal @@ -0,0 +1,495 @@ +cabal-version: 3.4 +name: cardano-diffusion +version: 0.1.0.0 +synopsis: A networking layer for the cardano blockchain protocol +description: A networking layer for the cardano blockchain protocol. +license: Apache-2.0 +license-file: LICENSE +author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts +maintainer: marcin.szamotulski@iohk.io +copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect +license-files: + LICENSE + NOTICE + +category: Network +build-type: Simple +extra-doc-files: CHANGELOG.md + +flag asserts + description: Enable assertions + manual: False + default: False + +flag cddl + description: Enable CDDL based tests of the CBOR encoding + manual: True + -- These tests need the cddl and the cbor-diag Ruby-package + default: True + +common ghc-options + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + ghc-options: + -Wall + -Wno-unticked-promoted-constructors + -Wcompat + -Wincomplete-uni-patterns + -Wincomplete-record-updates + -Wpartial-fields + -Widentities + -Wredundant-constraints + -Wunused-packages + + if flag(asserts) + ghc-options: -fno-ignore-asserts + +-- in tests librararies redundant constraints are sometimes useful (e.g. +-- by default truned off debug tracing might require extra constraints like +-- `Show` or `MonadSay`). +common ghc-options-tests + import: ghc-options + ghc-options: -Wno-redundant-constraints + +library api + import: ghc-options + visibility: public + hs-source-dirs: api/lib + exposed-modules: + Cardano.Network.ConsensusMode + Cardano.Network.FetchMode + Cardano.Network.NodeToClient.Version + Cardano.Network.NodeToNode.Version + Cardano.Network.PeerSelection.Bootstrap + Cardano.Network.PeerSelection.LocalRootPeers + Cardano.Network.PeerSelection.PeerTrustable + Cardano.Network.Types + + build-depends: + aeson, + base >=4.14 && <4.22, + cborg >=0.2.1 && <0.3, + deepseq, + nothunks, + ouroboros-network:api, + text >=1.2 && <2.2, + +test-suite api-tests + import: ghc-options + type: exitcode-stdio-1.0 + main-is: Main.hs + hs-source-dirs: api/tests + other-modules: + Test.Cardano.Network.NodeToClient.Version + Test.Cardano.Network.NodeToNode.Version + Test.Cardano.Network.Version + + build-depends: + QuickCheck, + base >=4.14 && <4.22, + cardano-diffusion:api, + ouroboros-network:api, + tasty, + tasty-hunit, + tasty-quickcheck, + with-utf8, + + ghc-options: + -rtsopts + +library + import: ghc-options + hs-source-dirs: lib + exposed-modules: + Cardano.Network.Diffusion + Cardano.Network.Diffusion.Configuration + Cardano.Network.Diffusion.Handlers + Cardano.Network.Diffusion.Policies + Cardano.Network.Diffusion.Topology + Cardano.Network.Diffusion.Types + Cardano.Network.LedgerPeerConsensusInterface + Cardano.Network.NodeToClient + Cardano.Network.NodeToNode + Cardano.Network.PeerSelection.Churn + Cardano.Network.PeerSelection.ExtraRootPeers + Cardano.Network.PeerSelection.Governor.Monitor + Cardano.Network.PeerSelection.Governor.PeerSelectionActions + Cardano.Network.PeerSelection.Governor.PeerSelectionState + Cardano.Network.PeerSelection.Governor.Types + Cardano.Network.PeerSelection.PeerSelectionActions + Cardano.Network.PeerSelection.PublicRootPeers + Cardano.Network.PeerSelection.State.LocalRootPeers + + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + other-extensions: + BangPatterns + DataKinds + EmptyCase + ExistentialQuantification + FlexibleContexts + FlexibleInstances + FunctionalDependencies + GADTSyntax + GADTs + GeneralizedNewtypeDeriving + MultiParamTypeClasses + NamedFieldPuns + OverloadedStrings + PolyKinds + RankNTypes + RecordWildCards + ScopedTypeVariables + TemplateHaskell + TupleSections + TypeApplications + TypeFamilies + TypeInType + + build-depends: + base >=4.14 && <4.22, + bytestring, + cardano-diffusion:{api, protocols}, + containers, + contra-tracer, + dns, + io-classes:{io-classes, si-timers, strict-stm} ^>=1.8, + monoidal-synchronisation, + network ^>=3.2.7, + network-mux, + ouroboros-network:{ouroboros-network, api, framework, protocols}, + random, + typed-protocols:{typed-protocols, stateful} ^>=1.1, + + if !os(windows) + build-depends: + unix + +library orphan-instances + import: ghc-options + visibility: public + hs-source-dirs: orphan-instances + exposed-modules: + Cardano.Network.OrphanInstances + + reexported-modules: + other-extensions: + BangPatterns + DataKinds + EmptyCase + ExistentialQuantification + FlexibleContexts + FlexibleInstances + FunctionalDependencies + GADTSyntax + GADTs + GeneralizedNewtypeDeriving + MultiParamTypeClasses + NamedFieldPuns + OverloadedStrings + PolyKinds + RankNTypes + RecordWildCards + ScopedTypeVariables + TemplateHaskell + TupleSections + TypeApplications + TypeFamilies + TypeInType + + build-depends: + aeson, + base >=4.14 && <4.22, + cardano-diffusion:{cardano-diffusion, api}, + containers, + ouroboros-network:{ouroboros-network, api, orphan-instances}, + +executable demo-chain-sync + import: ghc-options + hs-source-dirs: demo + main-is: chain-sync.hs + build-depends: + async, + base >=4.14 && <4.22, + bytestring, + cardano-diffusion, + containers, + contra-tracer, + directory, + infinite-list, + io-classes:{si-timers, strict-stm}, + network-mux, + optparse-applicative, + ouroboros-network:{ouroboros-network, api, api-tests-lib, framework, protocols}, + random, + serialise, + typed-protocols, + + ghc-options: + -threaded + -rtsopts + +library protocols + import: ghc-options + visibility: public + hs-source-dirs: protocols/lib + exposed-modules: + Cardano.Network.Protocol.Handshake.Codec + Cardano.Network.Protocol.LocalStateQuery.Codec + Cardano.Network.Protocol.LocalTxMonitor.Codec + Cardano.Network.Protocol.PeerSharing.Codec + + reexported-modules: + Ouroboros.Network.Protocol.BlockFetch.Client as Cardano.Network.Protocol.BlockFetch.Client, + Ouroboros.Network.Protocol.BlockFetch.Codec as Cardano.Network.Protocol.BlockFetch.Codec, + Ouroboros.Network.Protocol.BlockFetch.Server as Cardano.Network.Protocol.BlockFetch.Server, + Ouroboros.Network.Protocol.BlockFetch.Type as Cardano.Network.Protocol.BlockFetch.Type, + Ouroboros.Network.Protocol.ChainSync.Client as Cardano.Network.Protocol.ChainSync.Client, + Ouroboros.Network.Protocol.ChainSync.ClientPipelined as Cardano.Network.Protocol.ChainSync.ClientPipelined, + Ouroboros.Network.Protocol.ChainSync.Codec as Cardano.Network.Protocol.ChainSync.Codec, + Ouroboros.Network.Protocol.ChainSync.PipelineDecision as Cardano.Network.Protocol.ChainSync.PipelineDecision, + Ouroboros.Network.Protocol.ChainSync.Server as Cardano.Network.Protocol.ChainSync.Server, + Ouroboros.Network.Protocol.ChainSync.Type as Cardano.Network.Protocol.ChainSync.Type, + Ouroboros.Network.Protocol.Codec.Utils as Cardano.Network.Protocol.Codec.Utils, + Ouroboros.Network.Protocol.Handshake.Client as Cardano.Network.Protocol.Handshake.Client, + Ouroboros.Network.Protocol.Handshake.Server as Cardano.Network.Protocol.Handshake.Server, + Ouroboros.Network.Protocol.Handshake.Type as Cardano.Network.Protocol.Handshake.Type, + Ouroboros.Network.Protocol.KeepAlive.Client as Cardano.Network.Protocol.KeepAlive.Client, + Ouroboros.Network.Protocol.KeepAlive.Codec as Cardano.Network.Protocol.KeepAlive.Codec, + Ouroboros.Network.Protocol.KeepAlive.Server as Cardano.Network.Protocol.KeepAlive.Server, + Ouroboros.Network.Protocol.KeepAlive.Type as Cardano.Network.Protocol.KeepAlive.Type, + Ouroboros.Network.Protocol.LocalStateQuery.Client as Cardano.Network.Protocol.LocalStateQuery.Client, + Ouroboros.Network.Protocol.LocalStateQuery.Server as Cardano.Network.Protocol.LocalStateQuery.Server, + Ouroboros.Network.Protocol.LocalStateQuery.Type as Cardano.Network.Protocol.LocalStateQuery.Type, + Ouroboros.Network.Protocol.LocalTxMonitor.Client as Cardano.Network.Protocol.LocalTxMonitor.Client, + Ouroboros.Network.Protocol.LocalTxMonitor.Server as Cardano.Network.Protocol.LocalTxMonitor.Server, + Ouroboros.Network.Protocol.LocalTxMonitor.Type as Cardano.Network.Protocol.LocalTxMonitor.Type, + Ouroboros.Network.Protocol.LocalTxSubmission.Client as Cardano.Network.Protocol.LocalTxSubmission.Client, + Ouroboros.Network.Protocol.LocalTxSubmission.Codec as Cardano.Network.Protocol.LocalTxSubmission.Codec, + Ouroboros.Network.Protocol.LocalTxSubmission.Server as Cardano.Network.Protocol.LocalTxSubmission.Server, + Ouroboros.Network.Protocol.LocalTxSubmission.Type as Cardano.Network.Protocol.LocalTxSubmission.Type, + Ouroboros.Network.Protocol.PeerSharing.Client as Cardano.Network.Protocol.PeerSharing.Client, + Ouroboros.Network.Protocol.PeerSharing.Server as Cardano.Network.Protocol.PeerSharing.Server, + Ouroboros.Network.Protocol.PeerSharing.Type as Cardano.Network.Protocol.PeerSharing.Type, + Ouroboros.Network.Protocol.TxSubmission2.Client as Cardano.Network.Protocol.TxSubmission2.Client, + Ouroboros.Network.Protocol.TxSubmission2.Codec as Cardano.Network.Protocol.TxSubmission2.Codec, + Ouroboros.Network.Protocol.TxSubmission2.Server as Cardano.Network.Protocol.TxSubmission2.Server, + Ouroboros.Network.Protocol.TxSubmission2.Type as Cardano.Network.Protocol.TxSubmission2.Type, + + build-depends: + base >=4.12 && <4.22, + bytestring >=0.10 && <0.13, + cardano-diffusion:api, + cborg >=0.2.1 && <0.3, + io-classes ^>=1.8.0.1, + ouroboros-network:{api, framework, protocols}, + typed-protocols:{typed-protocols, stateful} ^>=1.1, + +library protocols-tests-lib + import: ghc-options + visibility: public + hs-source-dirs: protocols/tests-lib + exposed-modules: + Cardano.Network.Protocol.Handshake.Test + + reexported-modules: + Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL as Cardano.Network.Protocol.BlockFetch.Codec.CDDL, + Ouroboros.Network.Protocol.BlockFetch.Direct as Cardano.Network.Protocol.BlockFetch.Direct, + Ouroboros.Network.Protocol.BlockFetch.Examples as Cardano.Network.Protocol.BlockFetch.Examples, + Ouroboros.Network.Protocol.BlockFetch.Test as Cardano.Network.Protocol.BlockFetch.Test, + Ouroboros.Network.Protocol.ChainSync.Codec.CDDL as Cardano.Network.Protocol.ChainSync.Codec.CDDL, + Ouroboros.Network.Protocol.ChainSync.Direct as Cardano.Network.Protocol.ChainSync.Direct, + Ouroboros.Network.Protocol.ChainSync.DirectPipelined as Cardano.Network.Protocol.ChainSync.DirectPipelined, + Ouroboros.Network.Protocol.ChainSync.Examples as Cardano.Network.Protocol.ChainSync.Examples, + Ouroboros.Network.Protocol.ChainSync.ExamplesPipelined as Cardano.Network.Protocol.ChainSync.ExamplesPipelined, + Ouroboros.Network.Protocol.ChainSync.Test as Cardano.Network.Protocol.ChainSync.Test, + Ouroboros.Network.Protocol.Handshake.Direct as Cardano.Network.Protocol.Handshake.Direct, + Ouroboros.Network.Protocol.KeepAlive.Direct as Cardano.Network.Protocol.KeepAlive.Direct, + Ouroboros.Network.Protocol.KeepAlive.Examples as Cardano.Network.Protocol.KeepAlive.Examples, + Ouroboros.Network.Protocol.KeepAlive.Test as Cardano.Network.Protocol.KeepAlive.Test, + Ouroboros.Network.Protocol.LocalStateQuery.Codec.CDDL as Cardano.Network.Protocol.LocalStateQuery.Codec.CDDL, + Ouroboros.Network.Protocol.LocalStateQuery.Direct as Cardano.Network.Protocol.LocalStateQuery.Direct, + Ouroboros.Network.Protocol.LocalStateQuery.Examples as Cardano.Network.Protocol.LocalStateQuery.Examples, + Ouroboros.Network.Protocol.LocalStateQuery.Test as Cardano.Network.Protocol.LocalStateQuery.Test, + Ouroboros.Network.Protocol.LocalTxMonitor.Codec.CDDL as Cardano.Network.Protocol.LocalTxMonitor.Codec.CDDL, + Ouroboros.Network.Protocol.LocalTxMonitor.Direct as Cardano.Network.Protocol.LocalTxMonitor.Direct, + Ouroboros.Network.Protocol.LocalTxMonitor.Examples as Cardano.Network.Protocol.LocalTxMonitor.Examples, + Ouroboros.Network.Protocol.LocalTxMonitor.Test as Cardano.Network.Protocol.LocalTxMonitor.Test, + Ouroboros.Network.Protocol.LocalTxSubmission.Codec.CDDL as Cardano.Network.Protocol.LocalTxSubmission.Codec.CDDL, + Ouroboros.Network.Protocol.LocalTxSubmission.Direct as Cardano.Network.Protocol.LocalTxSubmission.Direct, + Ouroboros.Network.Protocol.LocalTxSubmission.Examples as Cardano.Network.Protocol.LocalTxSubmission.Examples, + Ouroboros.Network.Protocol.LocalTxSubmission.Test as Cardano.Network.Protocol.LocalTxSubmission.Test, + Ouroboros.Network.Protocol.PeerSharing.Direct as Cardano.Network.Protocol.PeerSharing.Direct, + Ouroboros.Network.Protocol.PeerSharing.Examples as Cardano.Network.Protocol.PeerSharing.Examples, + Ouroboros.Network.Protocol.PeerSharing.Test as Cardano.Network.Protocol.PeerSharing.Test, + Ouroboros.Network.Protocol.TxSubmission2.Codec.CDDL as Cardano.Network.Protocol.TxSubmission2.Codec.CDDL, + Ouroboros.Network.Protocol.TxSubmission2.Direct as Cardano.Network.Protocol.TxSubmission2.Direct, + Ouroboros.Network.Protocol.TxSubmission2.Examples as Cardano.Network.Protocol.TxSubmission2.Examples, + Ouroboros.Network.Protocol.TxSubmission2.Test as Cardano.Network.Protocol.TxSubmission2.Test, + + build-depends: + QuickCheck, + base >=4.14 && <4.22, + bytestring, + cardano-diffusion:api, + cborg, + containers, + contra-tracer, + io-classes, + io-sim, + ouroboros-network:{api, framework, protocols-tests-lib}, + tasty, + tasty-quickcheck, + text, + typed-protocols, + +test-suite protocols-tests + import: ghc-options + type: exitcode-stdio-1.0 + hs-source-dirs: protocols/tests + main-is: Main.hs + build-depends: + base >=4.14 && <4.22, + cardano-diffusion:protocols-tests-lib, + tasty, + + ghc-options: + -threaded + -Wall + -Wunused-packages + -rtsopts + +test-suite protocols-cddl + import: ghc-options + type: exitcode-stdio-1.0 + hs-source-dirs: protocols/cddl + main-is: Main.hs + + if flag(cddl) + buildable: True + else + buildable: False + + build-depends: + QuickCheck, + base >=4.14 && <4.22, + bytestring, + cardano-diffusion:{api, protocols, protocols-tests-lib}, + cborg, + containers, + directory, + filepath, + mtl, + network, + ouroboros-network:{api, api-tests-lib, protocols-tests-lib}, + process-extras, + quickcheck-instances, + serialise, + tasty, + tasty-hunit, + tasty-quickcheck, + temporary, + text, + typed-protocols:{typed-protocols, stateful}, + + ghc-options: + -threaded + -Wall + -rtsopts + -with-rtsopts=-M400m + +test-suite protocols-bench + import: ghc-options-tests + type: exitcode-stdio-1.0 + default-extensions: ImportQualifiedPost + hs-source-dirs: protocols/bench + main-is: Main.hs + build-depends: + base >=4.14 && <4.22, + bytestring, + cardano-diffusion:{api, protocols, protocols-tests-lib}, + cborg, + containers, + deepseq, + network, + ouroboros-network:{api, protocols-tests-lib}, + tasty-bench, + typed-protocols:{typed-protocols, stateful}, + + ghc-options: + -rtsopts + -with-rtsopts=-A32m + -with-rtsopts=-T + + -- Important for comparing benchmarks results against a baseline run. + -- Read: https://hackage.haskell.org/package/tasty-bench for details + if impl(ghc >=8.6) + ghc-options: -fproc-alignment=64 + +library cardano-diffusion-tests-lib + import: ghc-options-tests + visibility: public + hs-source-dirs: tests/lib + build-depends: + QuickCheck >=2.16, + aeson, + base >=4.14 && <4.22, + bytestring, + cardano-diffusion:{cardano-diffusion, api, orphan-instances, protocols-tests-lib}, + cardano-slotting, + cborg, + containers, + contra-tracer, + dns, + io-classes:{io-classes, si-timers, strict-stm}, + io-sim, + iproute, + monoidal-synchronisation, + network, + network-mux, + ouroboros-network:{ouroboros-network, api, api-tests-lib, framework, framework-tests-lib, orphan-instances, ouroboros-network-tests-lib, protocols, protocols-tests-lib, tests-lib}, + pipes, + pretty-simple, + psqueues, + random, + serialise, + tasty, + tasty-quickcheck, + time, + typed-protocols:{typed-protocols, examples}, + + exposed-modules: + Test.Cardano.Network.Diffusion.Policies + Test.Cardano.Network.Diffusion.Testnet + Test.Cardano.Network.Diffusion.Testnet.MiniProtocols + Test.Cardano.Network.Diffusion.Testnet.Simulation + Test.Cardano.Network.OrphanInstances.Tests + Test.Cardano.Network.PeerSelection + Test.Cardano.Network.PeerSelection.Gource + Test.Cardano.Network.PeerSelection.Instances + Test.Cardano.Network.PeerSelection.LocalRootPeers + Test.Cardano.Network.PeerSelection.MockEnvironment + Test.Cardano.Network.PeerSelection.PublicRootPeers + Test.Cardano.Network.PeerSelection.Utils + +-- Simulation tests, and IO tests which don't require native system calls. +-- (i.e. they don't require system call API provided by `Win32-network` or +-- `network` dependency). test-suite sim-tests +test-suite cardano-diffusion-sim-tests + import: ghc-options-tests + type: exitcode-stdio-1.0 + hs-source-dirs: tests/sim + main-is: Main.hs + build-depends: + base >=4.14 && <4.22, + cardano-diffusion:cardano-diffusion-tests-lib, + tasty, + with-utf8, + + ghc-options: + -fno-ignore-asserts + -threaded + -rtsopts + +RTS + -T + -RTS diff --git a/cardano-diffusion/changelog.d/20250922_173749_coot_packages.md b/cardano-diffusion/changelog.d/20250922_173749_coot_packages.md new file mode 100644 index 00000000000..c69bfbbe32c --- /dev/null +++ b/cardano-diffusion/changelog.d/20250922_173749_coot_packages.md @@ -0,0 +1,12 @@ +### Breaking + +- Initial release of `cardano-diffusion` package which is based on + `ourorboros-network:cardano-diffusion` with the following modifications: + - Removed `Cardano.Network.Types` module. `LedgerStateJudgement` is available + from `cardano-diffusion:api` package in + `Cardano.Network.LedgerStateJudgement` module. `NumberOfBigLedgerPeers` is + avaialble from `cardano-diffusion` in `Cardano.Network.PeerSelection` module. + - Added `Cardano.Network.PeerSelection` module which exports most of cardano + related `PeerSelection` APIs - you can simplify your imports with it. It + might be a good idea to imports this module qualified. + diff --git a/cardano-diffusion/changelog.d/scriv.ini b/cardano-diffusion/changelog.d/scriv.ini new file mode 100644 index 00000000000..2c3518ac606 --- /dev/null +++ b/cardano-diffusion/changelog.d/scriv.ini @@ -0,0 +1,14 @@ +[scriv] +format = md +insert_marker = Changelog entries +md_header_level = 2 +version = literal: cardano-diffusion.cabal: version +categories = Breaking, Non-Breaking +end_marker = scriv-end-here +fragment_directory = changelog.d +ghrel_template = {{body}} +main_branches = main +new_fragment_template = file: new_fragment.${config:format}.j2 +output_file = CHANGELOG.${config:format} +skip_fragments = README.* +entry_title_template = {%% if version %%}{{ version }} -- {%% endif %%}{{ date.strftime('%%Y-%%m-%%d') }} diff --git a/ouroboros-network/demo/chain-sync.hs b/cardano-diffusion/demo/chain-sync.hs similarity index 100% rename from ouroboros-network/demo/chain-sync.hs rename to cardano-diffusion/demo/chain-sync.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion.hs rename to cardano-diffusion/lib/Cardano/Network/Diffusion.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Configuration.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion/Configuration.hs similarity index 90% rename from ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Configuration.hs rename to cardano-diffusion/lib/Cardano/Network/Diffusion/Configuration.hs index cb8edc6a3e3..8727a6d541d 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Configuration.hs +++ b/cardano-diffusion/lib/Cardano/Network/Diffusion/Configuration.hs @@ -13,6 +13,8 @@ module Cardano.Network.Diffusion.Configuration , defaultChainSyncIdleTimeout , defaultBlockFetchConfiguration , defaultMiniProtocolParameters + , TxSubmissionLogicVersion (..) + , defaultTxSubmissionLogicVersion , srvPrefix -- * Re-exports , ChainSyncIdleTimeout (..) @@ -30,6 +32,8 @@ import Ouroboros.Network.PeerSelection.Governor.Types (PeerSelectionTargets (..)) import Ouroboros.Network.PeerSelection.RelayAccessPoint (SRVPrefix) import Ouroboros.Network.Protocol.ChainSync.Codec (ChainSyncIdleTimeout (..)) +import Ouroboros.Network.TxSubmission.Inbound.V2.Types + (TxSubmissionLogicVersion (..)) -- | Default number of bootstrap peers -- @@ -88,3 +92,8 @@ defaultBlockFetchConfiguration bfcSalt = bfcGenesisBFConfig = GenesisBlockFetchConfiguration { gbfcGracePeriod = 10 }, -- seconds bfcSalt } + +-- | The default logic version is the legacy one, the new one is still +-- experimental. +defaultTxSubmissionLogicVersion :: TxSubmissionLogicVersion +defaultTxSubmissionLogicVersion = TxSubmissionLogicV1 diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Handlers.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion/Handlers.hs similarity index 95% rename from ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Handlers.hs rename to cardano-diffusion/lib/Cardano/Network/Diffusion/Handlers.hs index 8376c3c7f54..47f035f520c 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Handlers.hs +++ b/cardano-diffusion/lib/Cardano/Network/Diffusion/Handlers.hs @@ -12,6 +12,7 @@ import Control.Monad.Class.MonadTime.SI import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers) import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano +import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano import Cardano.Network.Types (LedgerStateJudgement) import Control.Concurrent.Class.MonadSTM.Strict import Ouroboros.Network.ConnectionManager.Types @@ -35,6 +36,7 @@ sigUSR1Handler extraState Cardano.DebugPeerSelectionState extraFlags extraPeers extraCounters + Cardano.ExtraTrace IO -> STM IO UseLedgerPeers -> PeerSharing @@ -63,7 +65,7 @@ sigUSR1Handler tracersExtra getUseLedgerPeers ownPeerSharing getBootstrapPeers <*> upstreamyness metrics <*> fetchynessBlocks metrics <*> (Cardano.DebugPeerSelectionState <$> getLedgerStateJudgement) - <*> readAssociationMode + <*> Cardano.readAssociationMode getUseLedgerPeers ownPeerSharing useBootstrapPeers diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Policies.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion/Policies.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Policies.hs rename to cardano-diffusion/lib/Cardano/Network/Diffusion/Policies.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Topology.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion/Topology.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Topology.hs rename to cardano-diffusion/lib/Cardano/Network/Diffusion/Topology.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Types.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion/Types.hs similarity index 98% rename from ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Types.hs rename to cardano-diffusion/lib/Cardano/Network/Diffusion/Types.hs index f33789c8c2c..2f972df7b6f 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/Diffusion/Types.hs +++ b/cardano-diffusion/lib/Cardano/Network/Diffusion/Types.hs @@ -27,6 +27,7 @@ import Control.Concurrent.Class.MonadSTM.Strict import Control.Tracer (Tracer) import Network.Socket (SockAddr, Socket) +import Cardano.Network.ConsensusMode import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano import Cardano.Network.NodeToClient (LocalAddress, LocalSocket, NodeToClientVersion, NodeToClientVersionData) @@ -43,7 +44,6 @@ import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) import Cardano.Network.Types (NumberOfBigLedgerPeers (..)) import Ouroboros.Network.Diffusion qualified as Diffusion -import Ouroboros.Network.Diffusion.Configuration (ConsensusMode) import Ouroboros.Network.PeerSelection.Governor.Types (DebugPeerSelection, PeerSelectionCounters, PeerSelectionTargets (..), TracePeerSelection) import Ouroboros.Network.PeerSelection.LedgerPeers.Type @@ -107,6 +107,7 @@ type CardanoTracers m = PeerTrustable (Cardano.ExtraPeers RemoteAddress) (Cardano.ExtraPeerSelectionSetsWithSizes RemoteAddress) + Cardano.ExtraTrace m diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/LedgerPeerConsensusInterface.hs b/cardano-diffusion/lib/Cardano/Network/LedgerPeerConsensusInterface.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/LedgerPeerConsensusInterface.hs rename to cardano-diffusion/lib/Cardano/Network/LedgerPeerConsensusInterface.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToClient.hs b/cardano-diffusion/lib/Cardano/Network/NodeToClient.hs similarity index 96% rename from ouroboros-network/cardano-diffusion/Cardano/Network/NodeToClient.hs rename to cardano-diffusion/lib/Cardano/Network/NodeToClient.hs index 92292b4f505..387cac9e2af 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToClient.hs +++ b/cardano-diffusion/lib/Cardano/Network/NodeToClient.hs @@ -65,6 +65,11 @@ import Network.TypedProtocol.Peer.Client import Network.TypedProtocol.Stateful.Peer.Client qualified as Stateful import Cardano.Network.NodeToClient.Version +import Cardano.Network.Protocol.Handshake.Codec +import Cardano.Network.Protocol.LocalStateQuery.Client as LocalStateQuery +import Cardano.Network.Protocol.LocalStateQuery.Type qualified as LocalStateQuery +import Cardano.Network.Protocol.LocalTxMonitor.Client as LocalTxMonitor +import Cardano.Network.Protocol.LocalTxMonitor.Type qualified as LocalTxMonitor import Ouroboros.Network.Context import Ouroboros.Network.Driver (TraceSendRecv (..)) @@ -73,13 +78,8 @@ import Ouroboros.Network.IOManager import Ouroboros.Network.Mux import Ouroboros.Network.Protocol.ChainSync.Client as ChainSync import Ouroboros.Network.Protocol.ChainSync.Type qualified as ChainSync -import Ouroboros.Network.Protocol.Handshake.Codec import Ouroboros.Network.Protocol.Handshake.Type import Ouroboros.Network.Protocol.Handshake.Version hiding (Accept) -import Ouroboros.Network.Protocol.LocalStateQuery.Client as LocalStateQuery -import Ouroboros.Network.Protocol.LocalStateQuery.Type qualified as LocalStateQuery -import Ouroboros.Network.Protocol.LocalTxMonitor.Client as LocalTxMonitor -import Ouroboros.Network.Protocol.LocalTxMonitor.Type qualified as LocalTxMonitor import Ouroboros.Network.Protocol.LocalTxSubmission.Client as LocalTxSubmission import Ouroboros.Network.Protocol.LocalTxSubmission.Type qualified as LocalTxSubmission import Ouroboros.Network.Snocket diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToNode.hs b/cardano-diffusion/lib/Cardano/Network/NodeToNode.hs similarity index 99% rename from ouroboros-network/cardano-diffusion/Cardano/Network/NodeToNode.hs rename to cardano-diffusion/lib/Cardano/Network/NodeToNode.hs index 9e5aa4766c5..e25f712f305 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/NodeToNode.hs +++ b/cardano-diffusion/lib/Cardano/Network/NodeToNode.hs @@ -7,8 +7,6 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# OPTIONS_GHC -Wno-orphans #-} - -- | This is the starting point for a module that will bring together the -- overall node to node protocol, as a collection of mini-protocols. -- @@ -83,6 +81,7 @@ import Network.Socket (Socket, StructLinger (..)) import Network.Socket qualified as Socket import Cardano.Network.NodeToNode.Version +import Cardano.Network.Protocol.Handshake.Codec import Ouroboros.Network.ConnectionManager.Types (DataFlow (..), ExceptionInHandler (..)) @@ -95,7 +94,6 @@ import Ouroboros.Network.PeerSelection.Governor.Types (PeerSelectionTargets (..)) import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise (..)) import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) -import Ouroboros.Network.Protocol.Handshake.Codec import Ouroboros.Network.Protocol.Handshake.Type import Ouroboros.Network.Protocol.Handshake.Version hiding (Accept) import Ouroboros.Network.Protocol.TxSubmission2.Type (NumTxIdsToAck (..)) diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Churn.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs similarity index 99% rename from ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Churn.hs rename to cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs index de5ee2424d7..532c55be583 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Churn.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs @@ -31,6 +31,7 @@ import System.Random import Cardano.Network.ConsensusMode (ConsensusMode (..)) import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) +import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano import Cardano.Network.Types (LedgerStateJudgement (..)) import Control.Applicative (Alternative) import Data.Functor (($>)) @@ -120,6 +121,7 @@ peerChurnGovernor extraPeers (Cardano.LedgerPeersConsensusInterface m) extraCounters + Cardano.ExtraTrace peeraddr -> m Void peerChurnGovernor PeerChurnArgs { diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/ExtraRootPeers.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/ExtraRootPeers.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/ExtraRootPeers.hs rename to cardano-diffusion/lib/Cardano/Network/PeerSelection/ExtraRootPeers.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/Monitor.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs similarity index 95% rename from ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/Monitor.hs rename to cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs index a8ac6068911..4205851bdb9 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/Monitor.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs @@ -15,6 +15,7 @@ module Cardano.Network.PeerSelection.Governor.Monitor , monitorLedgerStateJudgement , monitorBootstrapPeersFlag , waitForSystemToQuiesce + , ExtraTrace (..) ) where import Data.Set qualified as Set @@ -26,13 +27,15 @@ import Control.Monad.Class.MonadTimer.SI import Cardano.Network.ConsensusMode import Cardano.Network.Diffusion.Configuration qualified as Cardano (srvPrefix) import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano -import Cardano.Network.PeerSelection.Bootstrap (isBootstrapPeersEnabled, - isNodeAbleToMakeProgress, requiresBootstrapPeers) +import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), + isBootstrapPeersEnabled, isNodeAbleToMakeProgress, + requiresBootstrapPeers) import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano import Cardano.Network.PeerSelection.Governor.PeerSelectionActions qualified as Cardano import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers +import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Cardano.Network.Types (LedgerStateJudgement (..)) import Control.Exception (assert) import Data.Map.Strict (Map) @@ -50,7 +53,6 @@ import Ouroboros.Network.PeerSelection.State.EstablishedPeers qualified as Estab import Ouroboros.Network.PeerSelection.State.KnownPeers qualified as KnownPeers import Ouroboros.Network.PeerSelection.State.LocalRootPeers (LocalRootConfig (..)) -import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Ouroboros.Network.PeerSelection.Types @@ -91,7 +93,7 @@ targetPeers peerconn -> Guarded (STM m) (TimedDecision m Cardano.ExtraState extraDebugState PeerTrustable - extraPeers peeraddr peerconn) + extraPeers ExtraTrace peeraddr peerconn) targetPeers Cardano.ExtraPeerSelectionActions { Cardano.genesisPeerSelectionTargets } @@ -212,6 +214,7 @@ localRoots -> Guarded (STM m) (TimedDecision m Cardano.ExtraState extraDebugState PeerTrustable (Cardano.ExtraPeers peeraddr) + ExtraTrace peeraddr peerconn) localRoots actions@PeerSelectionActions{ readLocalRootPeers , extraPeersAPI @@ -334,7 +337,7 @@ localRoots actions@PeerSelectionActions{ readLocalRootPeers $ Decision { decisionTrace = TraceLocalRootPeersChanged localRootPeers localRootPeers' - : [ TraceLedgerStateJudgementChanged YoungEnough + : [ ExtraTrace (TraceLedgerStateJudgementChanged YoungEnough) | ledgerStateJudgement /= ledgerStateJudgement' ], decisionState = st { @@ -407,7 +410,7 @@ monitorBootstrapPeersFlag peerconn -> Guarded (STM m) (TimedDecision m Cardano.ExtraState extraDebugState extraFlags - (Cardano.ExtraPeers peeraddr) peeraddr peerconn) + (Cardano.ExtraPeers peeraddr) ExtraTrace peeraddr peerconn) monitorBootstrapPeersFlag Cardano.ExtraPeerSelectionActions { Cardano.readUseBootstrapPeers } PeerSelectionActions { extraPeersAPI } st@PeerSelectionState { knownPeers @@ -433,7 +436,7 @@ monitorBootstrapPeersFlag Cardano.ExtraPeerSelectionActions { Cardano.readUseBoo (inProgressPromoteCold <> inProgressPromoteWarm) return $ \_now -> Decision { - decisionTrace = [TraceUseBootstrapPeersChanged ubp], + decisionTrace = [ExtraTrace (TraceUseBootstrapPeersChanged ubp)], decisionJobs = [], decisionState = st { knownPeers = @@ -490,7 +493,7 @@ monitorLedgerStateJudgement peerconn -> Guarded (STM m) (TimedDecision m Cardano.ExtraState extraDebugState extraFlags - (Cardano.ExtraPeers peeraddr) peeraddr peerconn) + (Cardano.ExtraPeers peeraddr) ExtraTrace peeraddr peerconn) monitorLedgerStateJudgement PeerSelectionActions{ getLedgerStateCtx = ledgerCtx@LedgerPeersConsensusInterface { lpExtraAPI = Cardano.LedgerPeersConsensusInterface { @@ -518,7 +521,7 @@ monitorLedgerStateJudgement PeerSelectionActions{ return $ \_now -> Decision { - decisionTrace = [TraceLedgerStateJudgementChanged lsj], + decisionTrace = [ExtraTrace (TraceLedgerStateJudgementChanged lsj)], decisionJobs = case (lsj, ledgerPeerSnapshot) of (TooOld, Just ledgerPeerSnapshot') -> [jobVerifyPeerSnapshot Cardano.srvPrefix ledgerPeerSnapshot' ledgerCtx] @@ -586,7 +589,7 @@ monitorLedgerStateJudgement PeerSelectionActions{ }) return $ \now -> Decision { - decisionTrace = [TraceLedgerStateJudgementChanged lsj], + decisionTrace = [ExtraTrace (TraceLedgerStateJudgementChanged lsj)], decisionJobs = [], decisionState = st' now } @@ -620,7 +623,7 @@ waitForSystemToQuiesce peerconn -> Guarded (STM m) (TimedDecision m Cardano.ExtraState extraDebugState PeerTrustable - (Cardano.ExtraPeers peeraddr) peeraddr peerconn) + (Cardano.ExtraPeers peeraddr) ExtraTrace peeraddr peerconn) waitForSystemToQuiesce st@PeerSelectionState{ knownPeers , localRootPeers @@ -670,3 +673,13 @@ waitForSystemToQuiesce st@PeerSelectionState{ } } | otherwise = GuardedSkip Nothing + + +-- | Extra trace points for `TracePeerSelection`. +-- +-- TODO: it ought to be moved to `Types`, but that introduces a circular +-- dependency. +data ExtraTrace = + TraceLedgerStateJudgementChanged LedgerStateJudgement + | TraceUseBootstrapPeersChanged UseBootstrapPeers + deriving Show diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/PeerSelectionActions.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/PeerSelectionActions.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/PeerSelectionActions.hs rename to cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/PeerSelectionActions.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs rename to cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/Types.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Types.hs similarity index 89% rename from ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/Types.hs rename to cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Types.hs index d3916aeabe7..1a896ac318b 100644 --- a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/Governor/Types.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Types.hs @@ -1,8 +1,15 @@ -{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NamedFieldPuns #-} -module Cardano.Network.PeerSelection.Governor.Types where +module Cardano.Network.PeerSelection.Governor.Types + ( ExtraPeerSelectionSetsWithSizes (..) + , empty + , cardanoPeerSelectionStatetoCounters + , outboundConnectionsState + , cardanoPeerSelectionGovernorArgs + , readAssociationMode + , Cardano.ExtraTrace (..) + ) where import Cardano.Network.ConsensusMode (ConsensusMode (..)) import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano @@ -19,6 +26,7 @@ import Cardano.Network.PeerSelection.LocalRootPeers (OutboundConnectionsState (..)) import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers +import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Cardano.Network.Types (LedgerStateJudgement (..), getNumberOfBigLedgerPeers) import Control.Applicative (Alternative) @@ -26,7 +34,7 @@ import Control.Concurrent.Class.MonadSTM import Control.Monad.Class.MonadTimer.SI import Data.Set (Set) import Data.Set qualified as Set -import Ouroboros.Network.PeerSelection.Governor (readAssociationMode) +import Ouroboros.Network.PeerSelection (PeerSharing (..), UseLedgerPeers (..)) import Ouroboros.Network.PeerSelection.Governor.Types (AssociationMode (..), BootstrapPeersCriticalTimeoutError (..), ExtraGuardedDecisions (..), PeerSelectionActions (..), PeerSelectionGovernorArgs (..), @@ -36,7 +44,6 @@ import Ouroboros.Network.PeerSelection.LedgerPeers (LedgerPeersConsensusInterface (lpExtraAPI)) import Ouroboros.Network.PeerSelection.PublicRootPeers (getBigLedgerPeers) import Ouroboros.Network.PeerSelection.State.EstablishedPeers qualified as EstablishedPeers -import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers -- | Peer selection view. -- @@ -197,6 +204,7 @@ cardanoPeerSelectionGovernorArgs (Cardano.ExtraPeers peeraddr) (Cardano.LedgerPeersConsensusInterface m) (ExtraPeerSelectionSetsWithSizes peeraddr) + Cardano.ExtraTrace peeraddr peerconn BootstrapPeersCriticalTimeoutError @@ -240,3 +248,30 @@ cardanoPeerSelectionGovernorArgs extraActions = st { Cardano.ledgerStateJudgement = YoungEnough } } } + + +-- | Classify if a node is in promiscuous mode. +-- +-- A node is not in promiscuous mode only if: it doesn't use ledger peers, peer +-- sharing, the set of bootstrap peers is empty. +-- +readAssociationMode + :: MonadSTM m + => STM m UseLedgerPeers + -> PeerSharing + -> UseBootstrapPeers + -> STM m AssociationMode +readAssociationMode + readUseLedgerPeers + peerSharing + useBootstrapPeers + = + do useLedgerPeers <- readUseLedgerPeers + pure $ + case (useLedgerPeers, peerSharing, useBootstrapPeers) of + (DontUseLedgerPeers, PeerSharingDisabled, DontUseBootstrapPeers) + -> LocalRootsOnly + (DontUseLedgerPeers, PeerSharingDisabled, UseBootstrapPeers config) + | null config + -> LocalRootsOnly + _ -> Unrestricted diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/PeerSelectionActions.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/PeerSelectionActions.hs rename to cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs diff --git a/ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/PublicRootPeers.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/PublicRootPeers.hs similarity index 100% rename from ouroboros-network/cardano-diffusion/Cardano/Network/PeerSelection/PublicRootPeers.hs rename to cardano-diffusion/lib/Cardano/Network/PeerSelection/PublicRootPeers.hs diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/State/LocalRootPeers.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/State/LocalRootPeers.hs new file mode 100644 index 00000000000..2cac03ffbe3 --- /dev/null +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/State/LocalRootPeers.hs @@ -0,0 +1,62 @@ +{-# LANGUAGE NamedFieldPuns #-} + +module Cardano.Network.PeerSelection.State.LocalRootPeers + ( clampToTrustable + , isPeerTrustable + , trustableKeysSet + , module Ouroboros.Network.PeerSelection.State.LocalRootPeers + ) where + + +import Data.Map.Strict qualified as Map +import Data.Set (Set) +import Data.Set qualified as Set + +import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) +import Ouroboros.Network.PeerSelection.State.LocalRootPeers + +clampToTrustable :: Ord peeraddr + => LocalRootPeers PeerTrustable peeraddr + -> LocalRootPeers PeerTrustable peeraddr +clampToTrustable (LocalRootPeers m gs) = + let trustedMap = Map.filter (\LocalRootConfig { extraFlags } -> case extraFlags of + IsTrustable -> True + IsNotTrustable -> False + ) + m + in LocalRootPeers trustedMap (trustedGroups gs) + where + trustedGroups [] = [] + trustedGroups ((h, w, g):gss) = + let trusted = Map.filter (\LocalRootConfig { extraFlags } -> case extraFlags of + IsTrustable -> True + IsNotTrustable -> False + ) + m + trustedSet = Map.keysSet trusted + trustedGroup = Set.intersection g trustedSet + w' = min w (WarmValency (Set.size trustedGroup)) + h' = HotValency (getHotValency h `min` getWarmValency w') + in if Set.null trustedGroup + then trustedGroups gss + else (h', w', trustedGroup) : trustedGroups gss + +isPeerTrustable :: Ord peeraddr + => peeraddr + -> LocalRootPeers PeerTrustable peeraddr + -> Bool +isPeerTrustable peeraddr lrp = + case Map.lookup peeraddr (toMap lrp) of + Just LocalRootConfig { extraFlags = IsTrustable } + -> True + _ -> False + +trustableKeysSet :: LocalRootPeers PeerTrustable peeraddr + -> Set peeraddr +trustableKeysSet (LocalRootPeers m _) = + Map.keysSet + . Map.filter (\LocalRootConfig { extraFlags } -> + case extraFlags of + IsTrustable -> True + IsNotTrustable -> False) + $ m diff --git a/ouroboros-network/orphan-instances/Cardano/Network/OrphanInstances.hs b/cardano-diffusion/orphan-instances/Cardano/Network/OrphanInstances.hs similarity index 91% rename from ouroboros-network/orphan-instances/Cardano/Network/OrphanInstances.hs rename to cardano-diffusion/orphan-instances/Cardano/Network/OrphanInstances.hs index 8f1fd702d55..2e32b7482e8 100644 --- a/ouroboros-network/orphan-instances/Cardano/Network/OrphanInstances.hs +++ b/cardano-diffusion/orphan-instances/Cardano/Network/OrphanInstances.hs @@ -16,6 +16,7 @@ import Cardano.Network.NodeToClient (NodeToClientVersion (..), import Cardano.Network.NodeToNode (NodeToNodeVersion (..), NodeToNodeVersionData (..)) import Cardano.Network.PeerSelection.Bootstrap +import Cardano.Network.PeerSelection.Governor.Types (ExtraTrace (..)) import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) import Cardano.Network.PeerSelection.PublicRootPeers (CardanoPublicRootPeers, getBootstrapPeers, getPublicConfigPeers) @@ -120,3 +121,13 @@ instance ToJSON (NetworkTopology UseBootstrapPeers PeerTrustable) where toJSON = networkTopologyToJSON (\useBootstrapPeers -> Just ("bootstrapPeers", toJSON useBootstrapPeers)) (\peerTrustable -> Just ("trustable", toJSON peerTrustable)) + +instance ToJSON ExtraTrace where + toJSON (TraceLedgerStateJudgementChanged new) = + object [ "kind" .= String "LedgerStateJudgementChanged" + , "LedgerStateJudgement" .= show new + ] + toJSON (TraceUseBootstrapPeersChanged ubp) = + object [ "kind" .= String "UseBootstrapPeersChanged" + , "UseBootstrapPeers" .= show ubp + ] diff --git a/ouroboros-network/protocols/bench/Main.hs b/cardano-diffusion/protocols/bench/Main.hs similarity index 92% rename from ouroboros-network/protocols/bench/Main.hs rename to cardano-diffusion/protocols/bench/Main.hs index 62e5964912a..4005676da6a 100644 --- a/ouroboros-network/protocols/bench/Main.hs +++ b/cardano-diffusion/protocols/bench/Main.hs @@ -26,33 +26,35 @@ import Cardano.Network.NodeToClient.Version import Cardano.Network.NodeToNode.Version import Ouroboros.Network.Block (SlotNo) -import Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL -import Ouroboros.Network.Protocol.BlockFetch.Type -import Ouroboros.Network.Protocol.ChainSync.Codec.CDDL -import Ouroboros.Network.Protocol.ChainSync.Type -import Ouroboros.Network.Protocol.ChainSync.Type qualified as ChainSync -import Ouroboros.Network.Protocol.Handshake.Codec -import Ouroboros.Network.Protocol.Handshake.Type -import Ouroboros.Network.Protocol.KeepAlive.Codec -import Ouroboros.Network.Protocol.KeepAlive.Type -import Ouroboros.Network.Protocol.KeepAlive.Type qualified as KeepAlive -import Ouroboros.Network.Protocol.LocalStateQuery.Codec.CDDL -import Ouroboros.Network.Protocol.LocalStateQuery.Test hiding (Query) -import Ouroboros.Network.Protocol.LocalStateQuery.Type -import Ouroboros.Network.Protocol.LocalStateQuery.Type qualified as LocalStateQuery -import Ouroboros.Network.Protocol.LocalTxMonitor.Codec.CDDL -import Ouroboros.Network.Protocol.LocalTxMonitor.Type -import Ouroboros.Network.Protocol.LocalTxMonitor.Type qualified as LocalTxMonitor -import Ouroboros.Network.Protocol.LocalTxSubmission.Codec.CDDL -import Ouroboros.Network.Protocol.LocalTxSubmission.Test qualified as LocalTxSubmission -import Ouroboros.Network.Protocol.LocalTxSubmission.Type -import Ouroboros.Network.Protocol.LocalTxSubmission.Type qualified as LocalTxSubmission -import Ouroboros.Network.Protocol.PeerSharing.Codec.CDDL -import Ouroboros.Network.Protocol.PeerSharing.Type -import Ouroboros.Network.Protocol.PeerSharing.Type qualified as PeerSharing -import Ouroboros.Network.Protocol.TxSubmission2.Codec.CDDL -import Ouroboros.Network.Protocol.TxSubmission2.Test -import Ouroboros.Network.Protocol.TxSubmission2.Type + +import Cardano.Network.Protocol.BlockFetch.Codec.CDDL +import Cardano.Network.Protocol.BlockFetch.Type +import Cardano.Network.Protocol.ChainSync.Codec.CDDL +import Cardano.Network.Protocol.ChainSync.Type +import Cardano.Network.Protocol.ChainSync.Type qualified as ChainSync +import Cardano.Network.Protocol.Handshake.Codec +import Cardano.Network.Protocol.Handshake.Type +import Cardano.Network.Protocol.KeepAlive.Codec +import Cardano.Network.Protocol.KeepAlive.Type +import Cardano.Network.Protocol.KeepAlive.Type qualified as KeepAlive +import Cardano.Network.Protocol.LocalStateQuery.Codec.CDDL +import Cardano.Network.Protocol.LocalStateQuery.Test hiding (Query) +import Cardano.Network.Protocol.LocalStateQuery.Type +import Cardano.Network.Protocol.LocalStateQuery.Type qualified as LocalStateQuery +import Cardano.Network.Protocol.LocalTxMonitor.Codec.CDDL +import Cardano.Network.Protocol.LocalTxMonitor.Type +import Cardano.Network.Protocol.LocalTxMonitor.Type qualified as LocalTxMonitor +import Cardano.Network.Protocol.LocalTxSubmission.Codec.CDDL +import Cardano.Network.Protocol.LocalTxSubmission.Test qualified as LocalTxSubmission +import Cardano.Network.Protocol.LocalTxSubmission.Type +import Cardano.Network.Protocol.LocalTxSubmission.Type qualified as LocalTxSubmission +import Cardano.Network.Protocol.PeerSharing.Codec +import Cardano.Network.Protocol.PeerSharing.Type +import Cardano.Network.Protocol.PeerSharing.Type qualified as PeerSharing +import Cardano.Network.Protocol.TxSubmission2.Codec.CDDL +import Cardano.Network.Protocol.TxSubmission2.Test +import Cardano.Network.Protocol.TxSubmission2.Type + import Test.Data.CDDL import Test.Tasty.Bench @@ -174,7 +176,7 @@ main = defaultMain AnyMessageAndAgency tok message -> show tok ++ " " ++ show message in concat [ benchmarkCodec ("PeerSharing " ++ printMsg msg ++ " " ++ show ntnVersion) - peerSharingCodec ntnVersion msg + codecPeerSharing ntnVersion msg | msg <- peerSharingMessages , ntnVersion <- [minBound .. maxBound] ] diff --git a/ouroboros-network/protocols/cddl/Main.hs b/cardano-diffusion/protocols/cddl/Main.hs similarity index 91% rename from ouroboros-network/protocols/cddl/Main.hs rename to cardano-diffusion/protocols/cddl/Main.hs index 2a1b331fecd..1c394d37217 100644 --- a/ouroboros-network/protocols/cddl/Main.hs +++ b/cardano-diffusion/protocols/cddl/Main.hs @@ -69,62 +69,59 @@ import Cardano.Network.NodeToNode.Version (DiffusionMode (..), import Cardano.Network.NodeToNode.Version qualified as NtNVersion import Ouroboros.Network.PeerSelection.RelayAccessPoint (PortNumber) -import Ouroboros.Network.Protocol.BlockFetch.Codec (codecBlockFetch) -import Ouroboros.Network.Protocol.BlockFetch.Test () -import Ouroboros.Network.Protocol.BlockFetch.Type (BlockFetch) -import Ouroboros.Network.Protocol.BlockFetch.Type qualified as BlockFetch -import Ouroboros.Network.Protocol.ChainSync.Codec (codecChainSync) -import Ouroboros.Network.Protocol.ChainSync.Test () -import Ouroboros.Network.Protocol.ChainSync.Type (ChainSync) -import Ouroboros.Network.Protocol.ChainSync.Type qualified as ChainSync -import Ouroboros.Network.Protocol.Handshake.Codec (nodeToClientHandshakeCodec, + +import Cardano.Network.Protocol.BlockFetch.Codec (codecBlockFetch) +import Cardano.Network.Protocol.BlockFetch.Codec.CDDL +import Cardano.Network.Protocol.BlockFetch.Test () +import Cardano.Network.Protocol.BlockFetch.Type (BlockFetch) +import Cardano.Network.Protocol.BlockFetch.Type qualified as BlockFetch +import Cardano.Network.Protocol.ChainSync.Codec (codecChainSync) +import Cardano.Network.Protocol.ChainSync.Codec.CDDL +import Cardano.Network.Protocol.ChainSync.Test () +import Cardano.Network.Protocol.ChainSync.Type (ChainSync) +import Cardano.Network.Protocol.ChainSync.Type qualified as ChainSync +import Cardano.Network.Protocol.Handshake.Codec (nodeToClientHandshakeCodec, nodeToNodeHandshakeCodec) -import Ouroboros.Network.Protocol.Handshake.Test (VersionNumber, - versionNumberHandshakeCodec) -import Ouroboros.Network.Protocol.Handshake.Type (Handshake) -import Ouroboros.Network.Protocol.Handshake.Type qualified as Handshake -import Ouroboros.Network.Protocol.KeepAlive.Codec (codecKeepAlive_v2) -import Ouroboros.Network.Protocol.KeepAlive.Test () -import Ouroboros.Network.Protocol.KeepAlive.Type (KeepAlive) -import Ouroboros.Network.Protocol.KeepAlive.Type qualified as KeepAlive -import Ouroboros.Network.Protocol.LocalStateQuery.Codec (codecLocalStateQuery) -import Ouroboros.Network.Protocol.LocalStateQuery.Codec qualified as LocalStateQuery -import Ouroboros.Network.Protocol.LocalStateQuery.Test qualified as LocalStateQuery -import Ouroboros.Network.Protocol.LocalStateQuery.Type (LocalStateQuery) -import Ouroboros.Network.Protocol.LocalStateQuery.Type qualified as LocalStateQuery -import Ouroboros.Network.Protocol.LocalTxMonitor.Codec (codecLocalTxMonitor) -import Ouroboros.Network.Protocol.LocalTxMonitor.Test qualified as LocalTxMonitor -import Ouroboros.Network.Protocol.LocalTxMonitor.Type (LocalTxMonitor) -import Ouroboros.Network.Protocol.LocalTxMonitor.Type qualified as LocalTxMonitor -import Ouroboros.Network.Protocol.LocalTxSubmission.Codec - (codecLocalTxSubmission) -import Ouroboros.Network.Protocol.LocalTxSubmission.Test qualified as LocalTxSubmission -import Ouroboros.Network.Protocol.LocalTxSubmission.Type (LocalTxSubmission) -import Ouroboros.Network.Protocol.LocalTxSubmission.Type qualified as LocalTxSubmission -import Ouroboros.Network.Protocol.TxSubmission2.Codec (codecTxSubmission2) -import Ouroboros.Network.Protocol.TxSubmission2.Test (Tx, TxId) -import Ouroboros.Network.Protocol.TxSubmission2.Type (TxSubmission2) -import Ouroboros.Network.Protocol.TxSubmission2.Type qualified as TxSubmission2 +-- import Cardano.Network.Protocol.Handshake.Test (VersionNumber, versionNumberHandshakeCodec) +import Cardano.Network.Protocol.Handshake.Type (Handshake) +import Cardano.Network.Protocol.Handshake.Type qualified as Handshake +import Cardano.Network.Protocol.KeepAlive.Codec (codecKeepAlive_v2) +import Cardano.Network.Protocol.KeepAlive.Test () +import Cardano.Network.Protocol.KeepAlive.Type (KeepAlive) +import Cardano.Network.Protocol.KeepAlive.Type qualified as KeepAlive +import Cardano.Network.Protocol.LocalStateQuery.Codec (codecLocalStateQuery) +import Cardano.Network.Protocol.LocalStateQuery.Codec qualified as LocalStateQuery +import Cardano.Network.Protocol.LocalStateQuery.Codec.CDDL +import Cardano.Network.Protocol.LocalStateQuery.Test qualified as LocalStateQuery +import Cardano.Network.Protocol.LocalStateQuery.Type (LocalStateQuery) +import Cardano.Network.Protocol.LocalStateQuery.Type qualified as LocalStateQuery +import Cardano.Network.Protocol.LocalTxMonitor.Codec (codecLocalTxMonitor) +import Cardano.Network.Protocol.LocalTxMonitor.Codec.CDDL +import Cardano.Network.Protocol.LocalTxMonitor.Test qualified as LocalTxMonitor +import Cardano.Network.Protocol.LocalTxMonitor.Type (LocalTxMonitor) +import Cardano.Network.Protocol.LocalTxMonitor.Type qualified as LocalTxMonitor +import Cardano.Network.Protocol.LocalTxSubmission.Codec (codecLocalTxSubmission) +import Cardano.Network.Protocol.LocalTxSubmission.Codec.CDDL +import Cardano.Network.Protocol.LocalTxSubmission.Test qualified as LocalTxSubmission +import Cardano.Network.Protocol.LocalTxSubmission.Type (LocalTxSubmission) +import Cardano.Network.Protocol.LocalTxSubmission.Type qualified as LocalTxSubmission +import Cardano.Network.Protocol.PeerSharing.Codec (codecPeerSharing) +import Cardano.Network.Protocol.PeerSharing.Test () +import Cardano.Network.Protocol.PeerSharing.Type qualified as PeerSharing +import Cardano.Network.Protocol.TxSubmission2.Codec (codecTxSubmission2) +import Cardano.Network.Protocol.TxSubmission2.Codec.CDDL +import Cardano.Network.Protocol.TxSubmission2.Test (Tx, TxId) +import Cardano.Network.Protocol.TxSubmission2.Type (TxSubmission2) +import Cardano.Network.Protocol.TxSubmission2.Type qualified as TxSubmission2 import Network.Socket (SockAddr (..)) import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) -import Ouroboros.Network.Protocol.PeerSharing.Codec (codecPeerSharing) -import Ouroboros.Network.Protocol.PeerSharing.Test () -import Ouroboros.Network.Protocol.PeerSharing.Type qualified as PeerSharing import Ouroboros.Network.Mock.ChainGenerators () import Ouroboros.Network.Mock.ConcreteBlock qualified as Concrete (Block) import Test.Data.CDDL (Any (..)) -import Ouroboros.Network.PeerSelection.PeerSharing.Codec (decodeRemoteAddress, - encodeRemoteAddress) -import Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL -import Ouroboros.Network.Protocol.ChainSync.Codec.CDDL -import Ouroboros.Network.Protocol.LocalStateQuery.Codec.CDDL -import Ouroboros.Network.Protocol.LocalTxMonitor.Codec.CDDL -import Ouroboros.Network.Protocol.LocalTxSubmission.Codec.CDDL -import Ouroboros.Network.Protocol.PeerSharing.Codec.CDDL -import Ouroboros.Network.Protocol.TxSubmission2.Codec.CDDL + import Test.QuickCheck hiding (Result (..)) import Test.QuickCheck.Instances.ByteString () import Test.Tasty (TestTree, adjustOption, defaultMain, testGroup) @@ -258,8 +255,8 @@ cddlc path = do readCDDLSpecs :: IO CDDLSpecs readCDDLSpecs = do dir <- bool ( "protocols" "cddl" "specs") -- False - ("ouroboros-network" "protocols" "cddl" "specs") -- True - <$> doesDirectoryExist "ouroboros-network" + ("cardano-diffusion" "protocols" "cddl" "specs") -- True + <$> doesDirectoryExist ("cardano-diffusion" "protocols") setEnv "CDDL_INCLUDE_PATH" (dir <> ":") handshakeNodeToClient <- cddlc (dir "handshake-node-to-client.cddl") @@ -589,7 +586,7 @@ prop_encodePeerSharingV14ToLast -> AnyMessage (PeerSharing.PeerSharing SockAddr) -> Property prop_encodePeerSharingV14ToLast spec (NtNVersionV14ToLast ntnVersion) = - validateEncoder spec (peerSharingCodec ntnVersion) + validateEncoder spec (codecPeerSharing ntnVersion) newtype NtNVersionV14ToLast = NtNVersionV14ToLast NodeToNodeVersion deriving Show @@ -944,7 +941,7 @@ unit_decodePeerSharingV14ToLast unit_decodePeerSharingV14ToLast spec = forM_ [NodeToNodeV_14 ..] $ \v -> validateDecoder Nothing - spec (peerSharingCodec v) + spec (codecPeerSharing v) [ SomeAgency PeerSharing.SingIdle , SomeAgency PeerSharing.SingBusy ] diff --git a/ouroboros-network/protocols/cddl/specs/block-fetch.cddl b/cardano-diffusion/protocols/cddl/specs/block-fetch.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/block-fetch.cddl rename to cardano-diffusion/protocols/cddl/specs/block-fetch.cddl diff --git a/ouroboros-network/protocols/cddl/specs/chain-sync.cddl b/cardano-diffusion/protocols/cddl/specs/chain-sync.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/chain-sync.cddl rename to cardano-diffusion/protocols/cddl/specs/chain-sync.cddl diff --git a/ouroboros-network/protocols/cddl/specs/handshake-node-to-client.cddl b/cardano-diffusion/protocols/cddl/specs/handshake-node-to-client.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/handshake-node-to-client.cddl rename to cardano-diffusion/protocols/cddl/specs/handshake-node-to-client.cddl diff --git a/ouroboros-network/protocols/cddl/specs/handshake-node-to-node-v14.cddl b/cardano-diffusion/protocols/cddl/specs/handshake-node-to-node-v14.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/handshake-node-to-node-v14.cddl rename to cardano-diffusion/protocols/cddl/specs/handshake-node-to-node-v14.cddl diff --git a/ouroboros-network/protocols/cddl/specs/keep-alive.cddl b/cardano-diffusion/protocols/cddl/specs/keep-alive.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/keep-alive.cddl rename to cardano-diffusion/protocols/cddl/specs/keep-alive.cddl diff --git a/ouroboros-network/protocols/cddl/specs/local-state-query.cddl b/cardano-diffusion/protocols/cddl/specs/local-state-query.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/local-state-query.cddl rename to cardano-diffusion/protocols/cddl/specs/local-state-query.cddl diff --git a/ouroboros-network/protocols/cddl/specs/local-tx-monitor.cddl b/cardano-diffusion/protocols/cddl/specs/local-tx-monitor.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/local-tx-monitor.cddl rename to cardano-diffusion/protocols/cddl/specs/local-tx-monitor.cddl diff --git a/ouroboros-network/protocols/cddl/specs/local-tx-submission.cddl b/cardano-diffusion/protocols/cddl/specs/local-tx-submission.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/local-tx-submission.cddl rename to cardano-diffusion/protocols/cddl/specs/local-tx-submission.cddl diff --git a/ouroboros-network/protocols/cddl/specs/network.base.cddl b/cardano-diffusion/protocols/cddl/specs/network.base.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/network.base.cddl rename to cardano-diffusion/protocols/cddl/specs/network.base.cddl diff --git a/ouroboros-network/protocols/cddl/specs/node-to-node-version-data-v14.cddl b/cardano-diffusion/protocols/cddl/specs/node-to-node-version-data-v14.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/node-to-node-version-data-v14.cddl rename to cardano-diffusion/protocols/cddl/specs/node-to-node-version-data-v14.cddl diff --git a/ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl b/cardano-diffusion/protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl rename to cardano-diffusion/protocols/cddl/specs/obsolete/handshake-node-to-node-v11-12.cddl diff --git a/ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl b/cardano-diffusion/protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl rename to cardano-diffusion/protocols/cddl/specs/obsolete/handshake-node-to-node-v13.cddl diff --git a/ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node.cddl b/cardano-diffusion/protocols/cddl/specs/obsolete/handshake-node-to-node.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/obsolete/handshake-node-to-node.cddl rename to cardano-diffusion/protocols/cddl/specs/obsolete/handshake-node-to-node.cddl diff --git a/ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl b/cardano-diffusion/protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl rename to cardano-diffusion/protocols/cddl/specs/obsolete/node-to-node-version-data-v11-12.cddl diff --git a/ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl b/cardano-diffusion/protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl rename to cardano-diffusion/protocols/cddl/specs/obsolete/node-to-node-version-data-v13.cddl diff --git a/ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data.cddl b/cardano-diffusion/protocols/cddl/specs/obsolete/node-to-node-version-data.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/obsolete/node-to-node-version-data.cddl rename to cardano-diffusion/protocols/cddl/specs/obsolete/node-to-node-version-data.cddl diff --git a/ouroboros-network/protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl b/cardano-diffusion/protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl rename to cardano-diffusion/protocols/cddl/specs/obsolete/peer-sharing-v11-12.cddl diff --git a/ouroboros-network/protocols/cddl/specs/obsolete/peer-sharing-v13.cddl b/cardano-diffusion/protocols/cddl/specs/obsolete/peer-sharing-v13.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/obsolete/peer-sharing-v13.cddl rename to cardano-diffusion/protocols/cddl/specs/obsolete/peer-sharing-v13.cddl diff --git a/ouroboros-network/protocols/cddl/specs/peer-sharing-v14.cddl b/cardano-diffusion/protocols/cddl/specs/peer-sharing-v14.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/peer-sharing-v14.cddl rename to cardano-diffusion/protocols/cddl/specs/peer-sharing-v14.cddl diff --git a/ouroboros-network/protocols/cddl/specs/tx-submission2.cddl b/cardano-diffusion/protocols/cddl/specs/tx-submission2.cddl similarity index 100% rename from ouroboros-network/protocols/cddl/specs/tx-submission2.cddl rename to cardano-diffusion/protocols/cddl/specs/tx-submission2.cddl diff --git a/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/Handshake/Codec.hs b/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/Handshake/Codec.hs new file mode 100644 index 00000000000..15a4f078c87 --- /dev/null +++ b/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/Handshake/Codec.hs @@ -0,0 +1,37 @@ +module Cardano.Network.Protocol.Handshake.Codec + ( nodeToNodeHandshakeCodec + , nodeToClientHandshakeCodec + , module Ouroboros.Network.Protocol.Handshake.Codec + ) where + +import Codec.CBOR.Read qualified as CBOR +import Codec.CBOR.Term qualified as CBOR +import Control.Monad.Class.MonadST +import Data.ByteString.Lazy qualified as BL + +import Network.TypedProtocol.Codec + +import Ouroboros.Network.Protocol.Handshake.Codec hiding (codecHandshake) +import Ouroboros.Network.Protocol.Handshake.Codec qualified as Handshake +import Ouroboros.Network.Protocol.Handshake.Type (Handshake) + +import Cardano.Network.NodeToClient.Version (NodeToClientVersion, + nodeToClientVersionCodec) +import Cardano.Network.NodeToNode.Version (NodeToNodeVersion, + nodeToNodeVersionCodec) + + +-- | 'Handshake' codec for the @node-to-node@ protocol suite. +-- +nodeToNodeHandshakeCodec :: MonadST m + => Codec (Handshake NodeToNodeVersion CBOR.Term) + CBOR.DeserialiseFailure m BL.ByteString +nodeToNodeHandshakeCodec = Handshake.codecHandshake nodeToNodeVersionCodec + + +-- | 'Handshake' codec for the @node-to-client@ protocol suite. +-- +nodeToClientHandshakeCodec :: MonadST m + => Codec (Handshake NodeToClientVersion CBOR.Term) + CBOR.DeserialiseFailure m BL.ByteString +nodeToClientHandshakeCodec = Handshake.codecHandshake nodeToClientVersionCodec diff --git a/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/LocalStateQuery/Codec.hs b/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/LocalStateQuery/Codec.hs new file mode 100644 index 00000000000..00f56ae3e02 --- /dev/null +++ b/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/LocalStateQuery/Codec.hs @@ -0,0 +1,49 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Cardano.Network.Protocol.LocalStateQuery.Codec + ( codecLocalStateQuery + , Codec.codecLocalStateQueryId + , Codec.Some (..) + ) where + +import Control.Monad.Class.MonadST + +import Codec.CBOR.Decoding qualified as CBOR +import Codec.CBOR.Encoding qualified as CBOR +import Codec.CBOR.Read qualified as CBOR +import Data.ByteString.Lazy (ByteString) + +import Network.TypedProtocol.Stateful.Codec qualified as Stateful + +import Cardano.Network.NodeToClient.Version + +import Ouroboros.Network.Protocol.LocalStateQuery.Codec qualified as Codec +import Ouroboros.Network.Protocol.LocalStateQuery.Type + +codecLocalStateQuery + :: forall block point query m. + ( MonadST m + , ShowQuery query + ) + => NodeToClientVersion + -- ^ eg whether to allow 'ImmutableTip' in @'MsgAcquire' + -> (point -> CBOR.Encoding) + -> (forall s . CBOR.Decoder s point) + -> (forall result . query result -> CBOR.Encoding) + -> (forall s . CBOR.Decoder s (Codec.Some query)) + -> (forall result . query result -> result -> CBOR.Encoding) + -> (forall result . query result -> forall s . CBOR.Decoder s result) + -> Stateful.Codec (LocalStateQuery block point query) CBOR.DeserialiseFailure State m ByteString +codecLocalStateQuery version = + Codec.codecLocalStateQuery localStateQueryVersion + where + localStateQueryVersion + | version < NodeToClientV_16 + = Codec.LocalStateQuery_V1 + | otherwise + = Codec.LocalStateQuery_V2 diff --git a/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/LocalTxMonitor/Codec.hs b/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/LocalTxMonitor/Codec.hs new file mode 100644 index 00000000000..a6f9fe5a8cc --- /dev/null +++ b/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/LocalTxMonitor/Codec.hs @@ -0,0 +1,48 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} + +module Cardano.Network.Protocol.LocalTxMonitor.Codec + ( codecLocalTxMonitor + , Codec.codecLocalTxMonitorId + ) where + +import Control.Monad.Class.MonadST + +import Codec.CBOR.Decoding qualified as CBOR +import Codec.CBOR.Encoding qualified as CBOR +import Codec.CBOR.Read qualified as CBOR +import Data.ByteString.Lazy (ByteString) + +import Network.TypedProtocol.Codec + +import Cardano.Network.NodeToClient.Version + +import Ouroboros.Network.Protocol.LocalTxMonitor.Codec qualified as Codec +import Ouroboros.Network.Protocol.LocalTxMonitor.Type + +codecLocalTxMonitor :: + forall txid tx slot m. + MonadST m + => NodeToClientVersion + -- ^ Whether to accept `MsgGetMeasures` + -> (txid -> CBOR.Encoding) + -> (forall s. CBOR.Decoder s txid) + -> (tx -> CBOR.Encoding) + -> (forall s. CBOR.Decoder s tx) + -> (slot -> CBOR.Encoding) + -> (forall s. CBOR.Decoder s slot) + -> Codec (LocalTxMonitor txid tx slot) CBOR.DeserialiseFailure m ByteString +codecLocalTxMonitor version = + Codec.codecLocalTxMonitor localTxMonitorVersion + where + localTxMonitorVersion + | version < NodeToClientV_20 + = Codec.LocalTxMonitor_V1 + | otherwise + = Codec.LocalTxMonitor_V2 diff --git a/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/PeerSharing/Codec.hs b/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/PeerSharing/Codec.hs new file mode 100644 index 00000000000..6d64eca1f84 --- /dev/null +++ b/cardano-diffusion/protocols/lib/Cardano/Network/Protocol/PeerSharing/Codec.hs @@ -0,0 +1,26 @@ +module Cardano.Network.Protocol.PeerSharing.Codec + ( codecPeerSharing + , Codec.codecPeerSharingId + , Codec.byteLimitsPeerSharing + , Codec.timeLimitsPeerSharing + ) where + +import Codec.CBOR.Read qualified as CBOR +import Data.ByteString.Lazy qualified as BL +import Network.TypedProtocol.Codec + +import Cardano.Network.NodeToNode.Version + +import Ouroboros.Network.PeerSelection.PeerSharing.Codec (decodeRemoteAddress, + encodeRemoteAddress) +import Ouroboros.Network.Protocol.PeerSharing.Codec qualified as Codec +import Ouroboros.Network.Protocol.PeerSharing.Type +import Ouroboros.Network.Snocket (RemoteAddress) + +codecPeerSharing :: NodeToNodeVersion + -> Codec (PeerSharing RemoteAddress) + CBOR.DeserialiseFailure IO BL.ByteString +codecPeerSharing ntnVersion = + Codec.codecPeerSharing (encodeRemoteAddress ntnVersion) + (decodeRemoteAddress ntnVersion) + diff --git a/cardano-diffusion/protocols/tests-lib/Cardano/Network/Protocol/Handshake/Test.hs b/cardano-diffusion/protocols/tests-lib/Cardano/Network/Protocol/Handshake/Test.hs new file mode 100644 index 00000000000..37194a4c7d6 --- /dev/null +++ b/cardano-diffusion/protocols/tests-lib/Cardano/Network/Protocol/Handshake/Test.hs @@ -0,0 +1,535 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DerivingVia #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} + +-- TODO: Needed for PeerSharing arbitrary instance see +-- todo there. +{-# OPTIONS_GHC -Wno-orphans #-} + +module Cardano.Network.Protocol.Handshake.Test where + +import Data.ByteString.Lazy (ByteString) +import Data.Map qualified as Map +import Data.Text (Text) + +import Codec.CBOR.Read qualified as CBOR +import Codec.CBOR.Term qualified as CBOR + +import Control.Monad.Class.MonadAsync +import Control.Monad.Class.MonadThrow +import Control.Monad.IOSim (runSimOrThrow) +import Control.Tracer (nullTracer) + +import Network.TypedProtocol.Codec + +import Cardano.Network.NodeToClient.Version as NTC +import Cardano.Network.NodeToNode.Version as NTN + +import Ouroboros.Network.Channel +import Ouroboros.Network.CodecCBORTerm +import Ouroboros.Network.Driver.Simple (runConnectedPeers) +import Ouroboros.Network.Magic +import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) + +import Ouroboros.Network.Protocol.Handshake.Client +import Ouroboros.Network.Protocol.Handshake.Codec +import Ouroboros.Network.Protocol.Handshake.Server +import Ouroboros.Network.Protocol.Handshake.Test hiding (tests) +import Ouroboros.Network.Protocol.Handshake.Type +import Ouroboros.Network.Protocol.Handshake.Version + +import Test.QuickCheck +import Test.Tasty (TestTree, testGroup) +import Test.Tasty.QuickCheck (testProperty) + +tests :: TestTree +tests = + testGroup "Ouroboros.Network.Protocol" + [ testGroup "Handshake" + [ testGroup "NodeToNode" + [ testProperty "acceptable_symmetric" + prop_acceptable_symmetric_NodeToNode + , testProperty "acceptOrRefuse" + prop_acceptOrRefuse_symmetric_NodeToNode + , testProperty "simultaneous open ST" + prop_channel_simultaneous_open_NodeToNode_ST + , testProperty "simultaneous open IO" + prop_channel_simultaneous_open_NodeToNode_IO + , testProperty "simultaneous open SimNet" + prop_channel_simultaneous_open_NodeToNode_SimNet + , testProperty "query version ST" + prop_query_version_NodeToNode_ST + , testProperty "query version IO" + prop_query_version_NodeToNode_IO + , testProperty "query version SimNet" + prop_query_version_NodeToNode_SimNet + , testProperty "peerSharing symmetry" + prop_peerSharing_symmetric_NodeToNode_SimNet + ] + + , testGroup "NodeToClient" + [ testProperty "acceptable_symmetric" + prop_acceptable_symmetric_NodeToClient + , testProperty "acceptOrRefuse" + prop_acceptOrRefuse_symmetric_NodeToClient + , testProperty "simultaneous open ST" + prop_channel_simultaneous_open_NodeToClient_ST + , testProperty "simultaneous open IO" + prop_channel_simultaneous_open_NodeToClient_IO + , testProperty "simultaneous open SimNet" + prop_channel_simultaneous_open_NodeToClient_SimNet + , testProperty "query version ST" + prop_query_version_NodeToClient_ST + , testProperty "query version IO" + prop_query_version_NodeToClient_IO + , testProperty "query version SimNet" + prop_query_version_NodeToClient_SimNet + ] + ] + ] + + + + +-- +-- NodeToNode generators +-- + +newtype ArbitraryNodeToNodeVersion = + ArbitraryNodeToNodeVersion { getNodeToNodeVersion :: NodeToNodeVersion } + deriving Show + +instance Arbitrary ArbitraryNodeToNodeVersion where + arbitrary = elements (ArbitraryNodeToNodeVersion <$> [minBound .. maxBound]) + +newtype ArbitraryNodeToNodeVersionData = + ArbitraryNodeToNodeVersionData + { getNodeToNodeVersionData :: NodeToNodeVersionData } + deriving Show + deriving Acceptable via NodeToNodeVersionData + +-- | With the introduction of PeerSharing to 'NodeToNodeVersionData' this type's +-- 'Acceptable' instance is no longer symmetric. Because when handshake is +-- performed we keep only the remote's side PeerSharing information. Due to this, +-- the 'ArbitraryNodeToNodeVersionData' needs to have a custom 'Eq' type that +-- ignores this parameter. We also ignore the query field which may differ +-- between parties. +-- +instance Eq ArbitraryNodeToNodeVersionData where + (==) (ArbitraryNodeToNodeVersionData (NodeToNodeVersionData nm dm ps _)) + (ArbitraryNodeToNodeVersionData (NodeToNodeVersionData nm' dm' ps' _)) + = nm == nm' && dm == dm' && ps == ps' + +instance Queryable ArbitraryNodeToNodeVersionData where + queryVersion = queryVersion . getNodeToNodeVersionData + +instance Arbitrary ArbitraryNodeToNodeVersionData where + arbitrary = fmap (fmap (fmap ArbitraryNodeToNodeVersionData)) + . NodeToNodeVersionData + <$> (NetworkMagic <$> arbitrary) + <*> elements [ InitiatorOnlyDiffusionMode + , InitiatorAndResponderDiffusionMode + ] + <*> elements [ PeerSharingDisabled + , PeerSharingEnabled + ] + <*> arbitrary + shrink (ArbitraryNodeToNodeVersionData + (NodeToNodeVersionData magic mode peerSharing query)) = + [ ArbitraryNodeToNodeVersionData (NodeToNodeVersionData magic' mode peerSharing' query) + | magic' <- NetworkMagic <$> shrink (unNetworkMagic magic) + , peerSharing' <- shrinkPeerSharing peerSharing + ] + ++ + [ ArbitraryNodeToNodeVersionData (NodeToNodeVersionData magic mode' peerSharing' query) + | mode' <- shrinkMode mode + , peerSharing' <- shrinkPeerSharing peerSharing + ] + ++ + [ ArbitraryNodeToNodeVersionData (NodeToNodeVersionData magic mode peerSharing' query') + | query' <- shrink query + , peerSharing' <- shrinkPeerSharing peerSharing + ] + where + shrinkMode :: DiffusionMode -> [DiffusionMode] + shrinkMode InitiatorOnlyDiffusionMode = [] + shrinkMode InitiatorAndResponderDiffusionMode = [InitiatorOnlyDiffusionMode] + + shrinkPeerSharing PeerSharingDisabled = [] + shrinkPeerSharing PeerSharingEnabled = [PeerSharingDisabled] + +newtype ArbitraryNodeToNodeVersions = + ArbitraryNodeToNodeVersions + { getArbitraryNodeToNodeVersiosn :: Versions NodeToNodeVersion + ArbitraryNodeToNodeVersionData Bool } + +instance Show ArbitraryNodeToNodeVersions where + show (ArbitraryNodeToNodeVersions (Versions vs)) + = "ArbitraryNodeToNodeVersions " ++ show (Map.map versionData vs) + +instance Arbitrary ArbitraryNodeToNodeVersions where + arbitrary = do + vs <- listOf (getNodeToNodeVersion <$> arbitrary) + ds <- vectorOf (length vs) arbitrary + r <- arbitrary + return $ ArbitraryNodeToNodeVersions + $ Versions + $ Map.fromList + [ (v, Version (const r) d) + | (v, d) <- zip vs ds + ] + -- TODO: shrink (issue #3407) + + +-- +-- NodeToClient generators +-- + +newtype ArbitraryNodeToClientVersion = + ArbitraryNodeToClientVersion { getNodeToClientVersion :: NodeToClientVersion } + deriving Show + +instance Arbitrary ArbitraryNodeToClientVersion where + arbitrary = elements (ArbitraryNodeToClientVersion <$> [minBound .. maxBound]) + +newtype ArbitraryNodeToClientVersionData = + ArbitraryNodeToClientVersionData + { getNodeToClientVersionData :: NodeToClientVersionData } + deriving Show + +instance Arbitrary ArbitraryNodeToClientVersionData where + arbitrary = ( (ArbitraryNodeToClientVersionData .) + . NodeToClientVersionData + ) + <$> (NetworkMagic <$> arbitrary) + <*> arbitrary + shrink (ArbitraryNodeToClientVersionData + (NodeToClientVersionData magic query)) = + [ ArbitraryNodeToClientVersionData (NodeToClientVersionData magic' query) + | magic' <- NetworkMagic <$> shrink (unNetworkMagic magic) + ] + ++ + [ ArbitraryNodeToClientVersionData (NodeToClientVersionData magic query') + | query' <- shrink query + ] + +newtype ArbitraryNodeToClientVersions = + ArbitraryNodeToClientVersions + { getArbitraryNodeToClientVersiosn :: Versions NodeToClientVersion + NodeToClientVersionData Bool } + +instance Show ArbitraryNodeToClientVersions where + show (ArbitraryNodeToClientVersions (Versions vs)) + = "ArbitraryNodeToClientVersions " ++ show (Map.map versionData vs) + +instance Arbitrary ArbitraryNodeToClientVersions where + arbitrary = do + vs <- listOf (getNodeToClientVersion <$> arbitrary) + ds <- vectorOf (length vs) (getNodeToClientVersionData <$> arbitrary) + r <- arbitrary + return $ ArbitraryNodeToClientVersions + $ Versions + $ Map.fromList + [ (v, Version (const r) d) + | (v, d) <- zip vs ds + ] + -- TODO: shrink (issue #3407) + + +prop_acceptable_symmetric_NodeToNode + :: ArbitraryNodeToNodeVersionData + -> ArbitraryNodeToNodeVersionData + -> Bool +prop_acceptable_symmetric_NodeToNode a b = + prop_acceptable_symmetric a b + + +prop_acceptable_symmetric_NodeToClient + :: ArbitraryNodeToClientVersionData + -> ArbitraryNodeToClientVersionData + -> Bool +prop_acceptable_symmetric_NodeToClient (ArbitraryNodeToClientVersionData a) + (ArbitraryNodeToClientVersionData b) = + prop_acceptable_symmetric a b + + +-- | Run 'prop_query_version' in the simulation monad. +-- +prop_query_version_NodeToNode_ST :: ArbitraryNodeToNodeVersions + -> ArbitraryNodeToNodeVersions + -> Property +prop_query_version_NodeToNode_ST + (ArbitraryNodeToNodeVersions clientVersions) + (ArbitraryNodeToNodeVersions serverVersions) = + runSimOrThrow $ prop_query_version + createConnectedChannels + (codecHandshake nodeToNodeVersionCodec) + (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) + clientVersions + serverVersions + (\(ArbitraryNodeToNodeVersionData vd) -> + ArbitraryNodeToNodeVersionData $ + vd { NTN.query = True + , NTN.peerSharing = PeerSharingEnabled + }) + +-- | Run 'prop_query_version' in the IO monad. +-- +prop_query_version_NodeToNode_IO :: ArbitraryNodeToNodeVersions + -> ArbitraryNodeToNodeVersions + -> Property +prop_query_version_NodeToNode_IO + (ArbitraryNodeToNodeVersions clientVersions) + (ArbitraryNodeToNodeVersions serverVersions) = + ioProperty $ prop_query_version + createConnectedChannels + (codecHandshake nodeToNodeVersionCodec) + (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) + clientVersions + serverVersions + (\(ArbitraryNodeToNodeVersionData vd) -> + ArbitraryNodeToNodeVersionData $ + vd { NTN.query = True + , NTN.peerSharing = PeerSharingEnabled + }) + +-- | Run 'prop_query_version' with SimNet. +-- +prop_query_version_NodeToNode_SimNet :: ArbitraryNodeToNodeVersions + -> ArbitraryNodeToNodeVersions + -> Property +prop_query_version_NodeToNode_SimNet + (ArbitraryNodeToNodeVersions clientVersions) + (ArbitraryNodeToNodeVersions serverVersions) = + runSimOrThrow $ prop_query_version + createConnectedChannels + (codecHandshake nodeToNodeVersionCodec) + (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) + clientVersions + serverVersions + (\(ArbitraryNodeToNodeVersionData vd) -> + ArbitraryNodeToNodeVersionData $ + vd { NTN.query = True + , NTN.peerSharing = PeerSharingEnabled + }) + +-- | Run 'prop_query_version' in the simulation monad. +-- +prop_query_version_NodeToClient_ST :: ArbitraryNodeToClientVersions + -> ArbitraryNodeToClientVersions + -> Property +prop_query_version_NodeToClient_ST + (ArbitraryNodeToClientVersions clientVersions) + (ArbitraryNodeToClientVersions serverVersions) = + runSimOrThrow $ prop_query_version + createConnectedChannels + (codecHandshake nodeToClientVersionCodec) + (cborTermVersionDataCodec nodeToClientCodecCBORTerm) + clientVersions + serverVersions + (\vd -> vd {NTC.query = True}) + +-- | Run 'prop_query_version' in the IO monad. +-- +prop_query_version_NodeToClient_IO :: ArbitraryNodeToClientVersions + -> ArbitraryNodeToClientVersions + -> Property +prop_query_version_NodeToClient_IO + (ArbitraryNodeToClientVersions clientVersions) + (ArbitraryNodeToClientVersions serverVersions) = + ioProperty $ prop_query_version + createConnectedChannels + (codecHandshake nodeToClientVersionCodec) + (cborTermVersionDataCodec nodeToClientCodecCBORTerm) + clientVersions + serverVersions + (\vd -> vd {NTC.query = True}) + +-- | Run 'prop_query_version' with SimNet. +-- +prop_query_version_NodeToClient_SimNet :: ArbitraryNodeToClientVersions + -> ArbitraryNodeToClientVersions + -> Property +prop_query_version_NodeToClient_SimNet + (ArbitraryNodeToClientVersions clientVersions) + (ArbitraryNodeToClientVersions serverVersions) = + runSimOrThrow $ prop_query_version + createConnectedChannels + (codecHandshake nodeToClientVersionCodec) + (cborTermVersionDataCodec nodeToClientCodecCBORTerm) + clientVersions + serverVersions + (\vd -> vd {NTC.query = True}) + + +-- | Run a query for the server's supported version. +-- +prop_peerSharing_symmetric :: + ( MonadAsync m + , MonadCatch m + ) + => m (Channel m ByteString, Channel m ByteString) + -> Codec (Handshake NodeToNodeVersion CBOR.Term) + CBOR.DeserialiseFailure m ByteString + -> VersionDataCodec CBOR.Term NodeToNodeVersion ArbitraryNodeToNodeVersionData + -> Versions NodeToNodeVersion ArbitraryNodeToNodeVersionData Bool + -> Versions NodeToNodeVersion ArbitraryNodeToNodeVersionData Bool + -> m Property +prop_peerSharing_symmetric createChannels codec versionDataCodec clientVersions serverVersions = do + (clientRes, serverRes) <- + runConnectedPeers + createChannels nullTracer codec + (handshakeClientPeer + versionDataCodec + acceptableVersion + clientVersions) + (handshakeServerPeer + versionDataCodec + acceptableVersion + queryVersion + serverVersions) + pure $ case (clientRes, serverRes) of + -- TODO: make this return ArbitraryNodeToNodeVersionData rather than a pair + -- of NodeToNodeVersionData + ( Right (HandshakeNegotiationResult _ v (ArbitraryNodeToNodeVersionData clientResult)) + , Right (HandshakeNegotiationResult _ v' (ArbitraryNodeToNodeVersionData serverResult)) + ) | v == v' + , v >= NodeToNodeV_14 -> + counterexample + ("VersionNumber: " ++ show v) + $ clientResult === serverResult + | v == v' + , v < NodeToNodeV_14 -> property True + | otherwise -> counterexample "Version mismatch" False + (Right _, Left _) -> counterexample "Acceptance mismatch" False + (Left _, Right _) -> counterexample "Acceptance mismatch" False + _ -> property True + +-- | Run 'prop_peerSharing_symmetric' with SimNet. +-- +prop_peerSharing_symmetric_NodeToNode_SimNet + :: ArbitraryNodeToNodeVersions + -> ArbitraryNodeToNodeVersions + -> Property +prop_peerSharing_symmetric_NodeToNode_SimNet + (ArbitraryNodeToNodeVersions clientVersions) + (ArbitraryNodeToNodeVersions serverVersions) = + runSimOrThrow $ prop_peerSharing_symmetric + createConnectedChannels + (codecHandshake nodeToNodeVersionCodec) + (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) + clientVersions + serverVersions + + +prop_acceptOrRefuse_symmetric_NodeToNode + :: ArbitraryNodeToNodeVersions + -> ArbitraryNodeToNodeVersions + -> Property +prop_acceptOrRefuse_symmetric_NodeToNode (ArbitraryNodeToNodeVersions a) + (ArbitraryNodeToNodeVersions b) = + + prop_acceptOrRefuse_symmetric a b + + +prop_acceptOrRefuse_symmetric_NodeToClient + :: ArbitraryNodeToClientVersions + -> ArbitraryNodeToClientVersions + -> Property +prop_acceptOrRefuse_symmetric_NodeToClient (ArbitraryNodeToClientVersions a) + (ArbitraryNodeToClientVersions b) = + + prop_acceptOrRefuse_symmetric a b + + +prop_channel_simultaneous_open_NodeToNode_ST :: ArbitraryNodeToNodeVersions + -> ArbitraryNodeToNodeVersions + -> Property +prop_channel_simultaneous_open_NodeToNode_ST + (ArbitraryNodeToNodeVersions clientVersions) + (ArbitraryNodeToNodeVersions serverVersions) = + runSimOrThrow $ prop_channel_simultaneous_open + createConnectedChannels + (codecHandshake nodeToNodeVersionCodec) + (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) + clientVersions + serverVersions + +transformNodeToNodeVersionData :: CodecCBORTerm Text NodeToNodeVersionData + -> CodecCBORTerm Text ArbitraryNodeToNodeVersionData +transformNodeToNodeVersionData (CodecCBORTerm g h) = + CodecCBORTerm { encodeTerm = \(ArbitraryNodeToNodeVersionData a) -> g a + , decodeTerm = fmap (fmap ArbitraryNodeToNodeVersionData) h + } + + +prop_channel_simultaneous_open_NodeToNode_IO :: ArbitraryNodeToNodeVersions + -> ArbitraryNodeToNodeVersions + -> Property +prop_channel_simultaneous_open_NodeToNode_IO + (ArbitraryNodeToNodeVersions clientVersions) + (ArbitraryNodeToNodeVersions serverVersions) = + ioProperty $ prop_channel_simultaneous_open + createConnectedChannels + (codecHandshake nodeToNodeVersionCodec) + (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) + clientVersions + serverVersions + + +prop_channel_simultaneous_open_NodeToClient_ST :: ArbitraryNodeToClientVersions + -> ArbitraryNodeToClientVersions + -> Property +prop_channel_simultaneous_open_NodeToClient_ST + (ArbitraryNodeToClientVersions clientVersions) + (ArbitraryNodeToClientVersions serverVersions) = + runSimOrThrow $ prop_channel_simultaneous_open + createConnectedChannels + (codecHandshake nodeToClientVersionCodec) + (cborTermVersionDataCodec nodeToClientCodecCBORTerm) + clientVersions + serverVersions + + +prop_channel_simultaneous_open_NodeToClient_IO :: ArbitraryNodeToClientVersions + -> ArbitraryNodeToClientVersions + -> Property +prop_channel_simultaneous_open_NodeToClient_IO + (ArbitraryNodeToClientVersions clientVersions) + (ArbitraryNodeToClientVersions serverVersions) = + ioProperty $ prop_channel_simultaneous_open + createConnectedChannels + (codecHandshake nodeToClientVersionCodec) + (cborTermVersionDataCodec nodeToClientCodecCBORTerm) + clientVersions + serverVersions + + +prop_channel_simultaneous_open_NodeToNode_SimNet :: ArbitraryNodeToNodeVersions + -> ArbitraryNodeToNodeVersions + -> Property +prop_channel_simultaneous_open_NodeToNode_SimNet + (ArbitraryNodeToNodeVersions clientVersions) + (ArbitraryNodeToNodeVersions serverVersions) = + runSimOrThrow $ prop_channel_simultaneous_open_sim + (codecHandshake nodeToNodeVersionCodec) + (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) + clientVersions + serverVersions + +prop_channel_simultaneous_open_NodeToClient_SimNet :: ArbitraryNodeToClientVersions + -> ArbitraryNodeToClientVersions + -> Property +prop_channel_simultaneous_open_NodeToClient_SimNet + (ArbitraryNodeToClientVersions clientVersions) + (ArbitraryNodeToClientVersions serverVersions) = + runSimOrThrow $ prop_channel_simultaneous_open_sim + (codecHandshake nodeToClientVersionCodec) + (cborTermVersionDataCodec nodeToClientCodecCBORTerm) + clientVersions + serverVersions diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs b/cardano-diffusion/protocols/tests-lib/Cardano/Network/Protocol/PeerSharing/Codec/CDDL.hs similarity index 90% rename from ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs rename to cardano-diffusion/protocols/tests-lib/Cardano/Network/Protocol/PeerSharing/Codec/CDDL.hs index ccaab605d3e..205f21b27be 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/PeerSharing/Codec/CDDL.hs +++ b/cardano-diffusion/protocols/tests-lib/Cardano/Network/Protocol/PeerSharing/Codec/CDDL.hs @@ -1,4 +1,4 @@ -module Ouroboros.Network.Protocol.PeerSharing.Codec.CDDL where +module Cardano.Network.Protocol.PeerSharing.Codec.CDDL (peerSharingCodec) where import Codec.CBOR.Read qualified as CBOR import Data.ByteString.Lazy qualified as BL diff --git a/cardano-diffusion/protocols/tests/Main.hs b/cardano-diffusion/protocols/tests/Main.hs new file mode 100644 index 00000000000..3596bd8ca2b --- /dev/null +++ b/cardano-diffusion/protocols/tests/Main.hs @@ -0,0 +1,16 @@ +module Main (main) where + +import Test.Tasty + +import Cardano.Network.Protocol.Handshake.Test qualified (tests) + +main :: IO () +main = defaultMain tests + +tests :: TestTree +tests = + testGroup "ouroboros-network-protocols" + + [ -- protocols + Cardano.Network.Protocol.Handshake.Test.tests + ] diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Policies.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Policies.hs similarity index 99% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Policies.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Policies.hs index bcee9149c16..793b096412c 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Policies.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Policies.hs @@ -6,7 +6,7 @@ {-# LANGUAGE ScopedTypeVariables #-} -module Test.Ouroboros.Network.Diffusion.Policies where +module Test.Cardano.Network.Diffusion.Policies where import Control.Concurrent.Class.MonadSTM.Strict import Control.Monad.Class.MonadTime.SI diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs similarity index 98% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs index f4b9e97b0ea..5101a7809d2 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs @@ -15,7 +15,7 @@ #endif {-# OPTIONS_GHC -Wno-unused-imports #-} -module Test.Ouroboros.Network.Diffusion.Testnet.Cardano (tests) where +module Test.Cardano.Network.Diffusion.Testnet (tests) where import Control.Exception (AssertionFailed (..), catch, displayException, evaluate, fromException) @@ -58,8 +58,10 @@ import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano.ExtraPeers import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano.ExtraState +import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) import Cardano.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers +import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Cardano.Network.Types (LedgerStateJudgement, NumberOfBigLedgerPeers (..)) import Ouroboros.Network.Block (BlockNo (..)) @@ -92,6 +94,8 @@ import Ouroboros.Network.TxSubmission.Outbound (TxSubmissionProtocolError (..)) import Simulation.Network.Snocket (BearerInfo (..), noAttenuation) +import Test.Cardano.Network.Diffusion.Testnet.Simulation + import Test.Ouroboros.Network.ConnectionManager.Timeouts import Test.Ouroboros.Network.ConnectionManager.Utils import Test.Ouroboros.Network.Data.AbsBearerInfo @@ -100,7 +104,6 @@ import Test.Ouroboros.Network.Data.Signal import Test.Ouroboros.Network.Data.Signal qualified as Signal import Test.Ouroboros.Network.Diffusion.Node (config_REPROMOTE_DELAY) import Test.Ouroboros.Network.Diffusion.Node.Kernel -import Test.Ouroboros.Network.Diffusion.Testnet.Cardano.Simulation import Test.Ouroboros.Network.InboundGovernor.Utils import Test.Ouroboros.Network.LedgerPeers (LedgerPools (..)) import Test.Ouroboros.Network.TxSubmission.TxLogic (ArbTxDecisionPolicy (..)) @@ -1206,9 +1209,9 @@ prop_only_bootstrap_peers_in_fallback_state ioSimTrace traceNumber = Signal.fromChangeEvents False . Signal.selectEvents (\case - TraceUseBootstrapPeersChanged UseBootstrapPeers{} - -> Just True - _ -> Nothing + ExtraTrace (Cardano.TraceUseBootstrapPeersChanged UseBootstrapPeers{}) + -> Just True + _ -> Nothing ) . selectDiffusionPeerSelectionEvents $ events @@ -1594,7 +1597,11 @@ prop_peer_selection_trace_coverage defaultBearerInfo diffScript = diffScript iosimTracer - events :: [TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) NtNAddr] + events :: [TracePeerSelection Cardano.ExtraState + PeerTrustable + (Cardano.ExtraPeers NtNAddr) + Cardano.ExtraTrace + NtNAddr] events = mapMaybe (\case DiffusionPeerSelectionTrace st -> Just st _ -> Nothing ) @@ -1610,7 +1617,11 @@ prop_peer_selection_trace_coverage defaultBearerInfo diffScript = :: ( Show extraDebugState , Show extraFlags , Show extraPeers - ) => TracePeerSelection extraDebugState extraFlags extraPeers NtNAddr -> String + ) + => TracePeerSelection extraDebugState extraFlags + extraPeers Cardano.ExtraTrace + NtNAddr + -> String peerSelectionTraceMap TraceLocalRootPeersChanged {} = "TraceLocalRootPeersChanged" peerSelectionTraceMap TraceTargetsChanged {} = @@ -1707,13 +1718,13 @@ prop_peer_selection_trace_coverage defaultBearerInfo diffScript = "TraceDemoteHotBigLedgerPeerDone" peerSelectionTraceMap TraceDemoteBigLedgerPeersAsynchronous {} = "TraceDemoteBigLedgerPeersAsynchronous" - peerSelectionTraceMap (TraceLedgerStateJudgementChanged lsj) = + peerSelectionTraceMap (ExtraTrace (Cardano.TraceLedgerStateJudgementChanged lsj)) = "TraceLedgerStateJudgementChanged " ++ show lsj peerSelectionTraceMap TraceOnlyBootstrapPeers = "TraceOnlyBootstrapPeers" peerSelectionTraceMap TraceBootstrapPeersFlagChangedWhilstInSensitiveState = "TraceBootstrapPeersFlagChangedWhilstInSensitiveState" - peerSelectionTraceMap (TraceUseBootstrapPeersChanged {}) = + peerSelectionTraceMap (ExtraTrace Cardano.TraceUseBootstrapPeersChanged {}) = "TraceUseBootstrapPeersChanged" peerSelectionTraceMap (TraceOutboundGovernorCriticalFailure {}) = "TraceOutboundGovernorCriticalFailure" @@ -4321,7 +4332,12 @@ unit_peer_sharing = script iosimTracer - events :: Map NtNAddr [TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) NtNAddr] + -- TODO: we need `CardanoTracePeerSelection addr` type alias! + events :: Map NtNAddr [TracePeerSelection Cardano.ExtraState + PeerTrustable + (Cardano.ExtraPeers NtNAddr) + Cardano.ExtraTrace + NtNAddr] events = Map.fromList . map (\as -> case as of [] -> -- this should be a test failure! @@ -4355,7 +4371,8 @@ unit_peer_sharing = $ runSimTrace sim verify :: NtNAddr - -> [TracePeerSelection extraDebugState extraFlags extraPeers NtNAddr] + -> [TracePeerSelection extraDebugState extraFlags + extraPeers extraTrace NtNAddr] -> Every verify addr as | addr == ip_2 = let receivedPeers :: Set NtNAddr @@ -4496,7 +4513,11 @@ prop_churn_notimeouts ioSimTrace traceNumber = $ ioSimTrace in conjoin $ (\evs -> - let psSig :: Signal (TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) NtNAddr) + let psSig :: Signal (TracePeerSelection Cardano.ExtraState + PeerTrustable + (Cardano.ExtraPeers NtNAddr) + Cardano.ExtraTrace + NtNAddr) psSig = fromChangeEvents TraceGovernorWakeup (selectDiffusionPeerSelectionEvents evs) -- We have 'True' when the governor is blocked @@ -4580,7 +4601,11 @@ prop_churn_steps ioSimTrace traceNumber = in conjoin $ (\evs -> - let evsList :: [(Time, TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) NtNAddr)] + let evsList :: [(Time, TracePeerSelection Cardano.ExtraState + PeerTrustable + (Cardano.ExtraPeers NtNAddr) + Cardano.ExtraTrace + NtNAddr)] evsList = eventsToList (selectDiffusionPeerSelectionEvents evs) in counterexample (List.intercalate "\n" (show <$> evsList)) . churnTracePredicate @@ -5058,7 +5083,11 @@ withTimeNameTraceEvents = traceSelectTraceEventsDynamic @(WithTime (WithName name b)) selectDiffusionPeerSelectionEvents :: Events DiffusionTestTrace - -> Events (TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) NtNAddr) + -> Events (TracePeerSelection Cardano.ExtraState + PeerTrustable + (Cardano.ExtraPeers NtNAddr) + Cardano.ExtraTrace + NtNAddr) selectDiffusionPeerSelectionEvents = Signal.selectEvents (\case DiffusionPeerSelectionTrace e -> Just e _ -> Nothing) @@ -5070,7 +5099,12 @@ selectDiffusionSimulationTrace = Signal.selectEvents _ -> Nothing) selectDiffusionPeerSelectionState :: Eq a - => (forall peerconn. Governor.PeerSelectionState Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) NtNAddr peerconn -> a) + => (forall peerconn. + Governor.PeerSelectionState Cardano.ExtraState + PeerTrustable + (Cardano.ExtraPeers NtNAddr) + NtNAddr peerconn + -> a) -> Events DiffusionTestTrace -> Signal a selectDiffusionPeerSelectionState f = diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/MiniProtocols.hs similarity index 99% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/MiniProtocols.hs index 315be610caa..e9e3a13c985 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/MiniProtocols.hs @@ -10,7 +10,8 @@ -- orphaned 'ShowProxy PingPong' instance. {-# OPTIONS_GHC -Wno-orphans #-} -module Test.Ouroboros.Network.Diffusion.Node.MiniProtocols +-- | Mini-protocols for `Test.Cardano.Network.Diffusion.Testnet`. +module Test.Cardano.Network.Diffusion.Testnet.MiniProtocols ( Codecs , cborCodecs , LimitsAndTimeouts (..) diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs similarity index 96% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs index 00f52df3dc5..58180dde485 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs @@ -11,7 +11,7 @@ {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -module Test.Ouroboros.Network.Diffusion.Testnet.Cardano.Simulation +module Test.Cardano.Network.Diffusion.Testnet.Simulation ( SimArgs (..) , renderSimArgs , mainnetSimArgs @@ -151,7 +151,7 @@ import Test.Ouroboros.Network.Diffusion.Node.Kernel (NtCAddr, NtCVersion, NtNVersionData, ppNtNAddr) import Test.Ouroboros.Network.LedgerPeers (LedgerPools (..), cardanoSRVPrefix, genLedgerPoolsFrom) -import Test.Ouroboros.Network.PeerSelection.Cardano.Instances () +import Test.Ouroboros.Network.PeerSelection.Instances (PeerAddr (..)) import Test.Ouroboros.Network.PeerSelection.Instances qualified as PeerSelection import Test.Ouroboros.Network.PeerSelection.LocalRootPeers () import Test.Ouroboros.Network.PeerSelection.RootPeersDNS (DNSLookupDelay (..), @@ -161,6 +161,10 @@ import Test.Ouroboros.Network.PeerSelection.RootPeersDNS qualified as PeerSelect import Test.Ouroboros.Network.TxSubmission.TxLogic (ArbTxDecisionPolicy (..)) import Test.Ouroboros.Network.TxSubmission.Types (Tx (..)) import Test.Ouroboros.Network.Utils + +import Test.Cardano.Network.Diffusion.Testnet.MiniProtocols qualified as Node +import Test.Cardano.Network.PeerSelection.Instances () + import Test.QuickCheck -- | Diffusion Simulator Arguments @@ -963,7 +967,7 @@ data DiffusionTestTrace = DiffusionLocalRootPeerTrace (TraceLocalRootPeers PeerTrustable NtNAddr) | DiffusionPublicRootPeerTrace TracePublicRootPeers | DiffusionLedgerPeersTrace TraceLedgerPeers - | DiffusionPeerSelectionTrace (Governor.TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) NtNAddr) + | DiffusionPeerSelectionTrace (Governor.TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) Cardano.ExtraTrace NtNAddr) | DiffusionPeerSelectionActionsTrace (PeerSelectionActionsTrace NtNAddr NtNVersion) | DiffusionDebugPeerSelectionTrace (DebugPeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) NtNAddr) | DiffusionConnectionManagerTrace @@ -1178,6 +1182,8 @@ diffusionSimulation onlyOutboundConnectionsStateVar <- newTVarIO UntrustedState useBootstrapPeersScriptVar <- newTVarIO bootstrapPeers churnModeVar <- newTVarIO ChurnModeNormal + peerMetrics <- newPeerMetric PeerMetricsConfiguration { maxEntriesToTrack = 180 } + policyStdGenVar <- newTVarIO (mkStdGen 12) let readUseBootstrapPeers = stepScriptSTM' useBootstrapPeersScriptVar (bgaRng, rng) = Random.split $ mkStdGen seed @@ -1259,6 +1265,7 @@ diffusionSimulation writeTVar onlyOutboundConnectionsStateVar a } , Node.iConnStateIdSupply = connStateIdSupply + , Node.iSRVPrefix = Cardano.srvPrefix } shouldChainSyncExit :: StrictTVar m (Maybe BlockNo) -> BlockHeader -> m Bool @@ -1323,8 +1330,51 @@ diffusionSimulation (pure TooOld) readPublicRootPeers - Node.run blockGeneratorArgs - limitsAndTimeouts + + tracerTxLogic = + contramap DiffusionTxLogic + . tracerWithName addr + . tracerWithTime + $ nodeTracer + + -- TODO: can we remove all `NodeArguments` fields that appear in + -- this function + mkApps + nodeKernel + keepAliveStdGen + = + Node.applications + (Node.aDebugTracer arguments) + tracerTxSubmissionInbound + tracerTxLogic + nodeKernel + Node.cborCodecs + limitsAndTimeouts + appArgs + blockHeader + where + tracerTxSubmissionInbound = + contramap DiffusionTxSubmissionInbound + . tracerWithName addr + . tracerWithTime + $ nodeTracer + + appArgs :: Node.AppArgs BlockHeader Block m + appArgs = Node.AppArgs + { Node.aaKeepAliveStdGen = keepAliveStdGen + , Node.aaPolicyStdGen = policyStdGenVar + , Node.aaDiffusionMode = Node.aDiffusionMode arguments + , Node.aaKeepAliveInterval = Node.aKeepAliveInterval arguments + , Node.aaPingPongInterval = Node.aPingPongInterval arguments + , Node.aaShouldChainSyncExit = Node.aShouldChainSyncExit arguments + , Node.aaChainSyncEarlyExit = Node.aChainSyncEarlyExit arguments + , Node.aaPeerSharing = Node.aPeerSharing arguments + , Node.aaPeerMetrics = peerMetrics + , Node.aaTxDecisionPolicy = Node.aTxDecisionPolicy arguments + } + + Node.run + blockGeneratorArgs interfaces arguments (ExtraState.empty consensusMode (NumberOfBigLedgerPeers 0)) @@ -1344,14 +1394,8 @@ diffusionSimulation . tracerWithName addr . tracerWithTime $ nodeTracer) - ( contramap DiffusionTxSubmissionInbound - . tracerWithName addr - . tracerWithTime - $ nodeTracer) - ( contramap DiffusionTxLogic - . tracerWithName addr - . tracerWithTime - $ nodeTracer) + tracerTxLogic + mkApps `catch` \e -> traceWith (diffSimTracer addr) (TrErrored e) >> throwIO e `finally` traceWith (diffSimTracer addr) TrTerminated @@ -1404,7 +1448,9 @@ diffusionSimulation Cardano.ExtraState Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers NtNAddr) - (Cardano.ExtraPeerSelectionSetsWithSizes NtNAddr) m + (Cardano.ExtraPeerSelectionSetsWithSizes NtNAddr) + Cardano.ExtraTrace + m mkTracers ntnAddr i = let sayTracer' = Tracer \msg -> say $ "(node-" <> show i <> ")" <> show msg -- toggle and uncomment interesting sayTracer' below diff --git a/ouroboros-network/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs similarity index 93% rename from ouroboros-network/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs index eb95226f0a3..27fb9341e05 100644 --- a/ouroboros-network/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/OrphanInstances/Tests.hs @@ -2,9 +2,10 @@ module Test.Cardano.Network.OrphanInstances.Tests (tests) where import Data.Aeson -import Cardano.Network.OrphanInstances () import Ouroboros.Network.OrphanInstances () -import Ouroboros.Network.Protocol.Handshake.Test hiding (tests) + +import Cardano.Network.OrphanInstances () +import Cardano.Network.Protocol.Handshake.Test hiding (tests) import Test.QuickCheck import Test.Tasty diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs similarity index 97% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs index 4a71619db41..1d01b9b738b 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs @@ -23,7 +23,10 @@ {-# OPTIONS_GHC -Wno-x-partial #-} #endif -module Test.Ouroboros.Network.PeerSelection (tests) where +-- TODO: +-- we should have `Test.Ouroboros.Network.PeerSelection` tests in +-- `ouroboros-network` too, them some of these tests might not be needed. +module Test.Cardano.Network.PeerSelection (tests) where import Control.Concurrent.Class.MonadSTM.Strict import Control.Exception (AssertionFailed (..), catch, evaluate) @@ -53,12 +56,13 @@ import Network.DNS qualified as DNS (defaultResolvConf) import Network.Socket (SockAddr) import Cardano.Network.ConsensusMode -import Ouroboros.Network.DiffusionMode import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), requiresBootstrapPeers) import Cardano.Network.PeerSelection.LocalRootPeers (OutboundConnectionsState) import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers + +import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy (RepromoteDelay (..)) import Ouroboros.Network.PeerSelection.Governor hiding (PeerSelectionState (..), peerSharing) @@ -79,15 +83,14 @@ import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRo import Ouroboros.Network.Point import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingResult (..)) +import Test.Cardano.Network.PeerSelection.MockEnvironment hiding (tests) +import Test.Cardano.Network.PeerSelection.Utils import Test.Ouroboros.Network.Data.Script import Test.Ouroboros.Network.Data.Signal (E (E), Events, Signal, TS (TS), signalProperty) import Test.Ouroboros.Network.Data.Signal qualified as Signal -import Test.Ouroboros.Network.PeerSelection.Cardano.MockEnvironment hiding - (tests) import Test.Ouroboros.Network.PeerSelection.Instances import Test.Ouroboros.Network.PeerSelection.PeerGraph -import Test.Ouroboros.Network.PeerSelection.Utils import Test.Ouroboros.Network.Utils (disjointSetsProperty, isSubsetProperty, nightlyTest) @@ -101,6 +104,7 @@ import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Ca import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano.ExtraState import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano.ExtraSizes +import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Cardano.Network.Types (LedgerStateJudgement (..), NumberOfBigLedgerPeers (..)) import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..)) @@ -236,6 +240,7 @@ prop_peerSelectionView_sizes env = @PeerTrustable @_ @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace (Time (10 * 3600)) trace in property $ foldMap (\(_, TraceGovernorState _ _ st) -> @@ -460,6 +465,7 @@ prop_governor_hasoutput env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace trace in counterexample (unlines ["\nSIM TRACE", ppTrace trace]) @@ -467,7 +473,8 @@ prop_governor_hasoutput env = $ hasOutput env (selectGovernorEvents evs) hasOutput :: GovernorMockEnvironment - -> [(Time, TracePeerSelection extraDebugState extraFlags extraPeers PeerAddr)] + -> [(Time, TracePeerSelection extraDebugState extraFlags + extraPeers extraTrace PeerAddr)] -> Bool hasOutput _ (_:_) = True hasOutput env [] = isEmptyEnv env @@ -522,6 +529,7 @@ prop_governor_nofail env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace $ ioSimTrace -- run in `IO` so we can catch the pure 'AssertionFailed' exception @@ -592,6 +600,7 @@ check_governor_nolivelock n trace0 = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace $ trace0 in case tooManyEventsBeforeTimeAdvances 1000 trace of Nothing -> property True @@ -684,6 +693,7 @@ prop_governor_nobusyness env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace $ runGovernorInMockEnvironment env in case tooBusyForTooLong (takeFirstNHours 10 trace) of @@ -699,9 +709,11 @@ prop_governor_nobusyness env = property False -- -tooBusyForTooLong :: [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)] +tooBusyForTooLong :: [(Time, TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace)] -> Maybe (Time, Time, DiffTime, - [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)]) + [(Time, TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace)]) tooBusyForTooLong trace0 = -- Pass in each timed event, with the diff-time to the next event idle [ (t, diffTime t' t, e) @@ -722,8 +734,17 @@ tooBusyForTooLong trace0 = -- and busy. In the idle state, the next (non-debug) event flips us into -- the busy state, starting with some minimal initial credits. - idle :: [(Time, DiffTime, TestTraceEvent extraState extraFlags extraPeers extraCounters)] - -> Maybe (Time, Time, DiffTime, [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)]) + idle :: [( Time + , DiffTime + , TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace + )] + -> Maybe ( Time + , Time + , DiffTime + , [(Time, TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace)] + ) idle [] = Nothing idle ((_, _, GovernorDebug{}):trace') = idle trace' idle trace@((busyStartTime,_,_):_) = @@ -740,8 +761,13 @@ tooBusyForTooLong trace0 = _ -> True ] - busy :: Time -> DiffTime -> [(Time, DiffTime, TestTraceEvent extraState extraFlags extraPeers extraCounters)] - -> Either (Time, DiffTime) [(Time, DiffTime, TestTraceEvent extraState extraFlags extraPeers extraCounters)] + busy :: Time + -> DiffTime + -> [(Time, DiffTime, TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace)] + -> Either (Time, DiffTime) + [(Time, DiffTime, TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace)] -- For normal governor events we check if the length of the busy time span -- is now too big (adjusted for any perturbation credits). If so we've @@ -865,6 +891,7 @@ prop_governor_events_coverage env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -891,6 +918,7 @@ prop_governor_trace_coverage env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace $ runGovernorInMockEnvironment env traceNumsSeen = collectTraces trace @@ -902,11 +930,13 @@ prop_governor_trace_coverage env = --TODO: use cover to check we do indeed get them all. There are a few -- cases we do not cover yet. These should be fixed first. -collectTraces :: [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)] -> Set Int +collectTraces :: [(Time, TestTraceEvent extraState extraFlags extraPeers + extraCounters Cardano.ExtraTrace)] + -> Set Int collectTraces trace = Set.fromList [ traceNum e | (_, GovernorEvent e) <- trace ] -traceNum :: TracePeerSelection extraDebugState extraFlags extraPeers peeraddr -> Int +traceNum :: TracePeerSelection extraDebugState extraFlags extraPeers Cardano.ExtraTrace peeraddr -> Int traceNum TraceLocalRootPeersChanged{} = 00 traceNum TraceTargetsChanged{} = 01 traceNum TracePublicRootsRequest{} = 02 @@ -955,10 +985,11 @@ traceNum TraceDemoteHotBigLedgerPeerFailed{} = 44 traceNum TraceDemoteHotBigLedgerPeerDone{} = 45 traceNum TracePickInboundPeers{} = 46 traceNum TraceDemoteBigLedgerPeersAsynchronous{} = 47 -traceNum TraceLedgerStateJudgementChanged{} = 48 +traceNum (ExtraTrace Cardano.TraceLedgerStateJudgementChanged{}) + = 48 traceNum TraceOnlyBootstrapPeers{} = 49 traceNum TraceBootstrapPeersFlagChangedWhilstInSensitiveState = 50 -traceNum TraceUseBootstrapPeersChanged {} = 51 +traceNum (ExtraTrace Cardano.TraceUseBootstrapPeersChanged {})= 51 traceNum TraceOutboundGovernorCriticalFailure {} = 52 traceNum TraceDebugState {} = 53 traceNum TraceChurnAction {} = 54 @@ -1055,10 +1086,13 @@ prop_governor_peershare_1hr env@GovernorMockEnvironment { @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace ioSimTrace Just found = knownPeersAfter1Hour trace reachable = peerShareReachablePeers peerGraph - (LocalRootPeers.keysSet localRootPeers <> PublicRootPeers.toSet Cardano.ExtraPeers.toSet publicRootPeers) + ( LocalRootPeers.keysSet localRootPeers + <> PublicRootPeers.toSet Cardano.ExtraPeers.toSet publicRootPeers + ) in counterexample ( intercalate "\n" . map (ppSimEvent 20 20 20) . takeWhile (\e -> seTime e <= Time (60*60)) @@ -1071,7 +1105,9 @@ prop_governor_peershare_1hr env@GovernorMockEnvironment { targets' :: (PeerSelectionTargets, PeerSelectionTargets) targets' = fst (scriptHead targets) - knownPeersAfter1Hour :: [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)] -> Maybe (Set PeerAddr) + knownPeersAfter1Hour :: [(Time, TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace)] + -> Maybe (Set PeerAddr) knownPeersAfter1Hour trace = listToMaybe [ KnownPeers.toSet (Governor.knownPeers st) @@ -1113,6 +1149,7 @@ check_governor_connstatus _ trace0 = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace $ trace0 --TODO: check any actually get a true status output and try some deliberate bugs in @@ -1129,8 +1166,9 @@ check_governor_connstatus _ trace0 = , Show extraFlags , Show extraPeers , Show extraCounters + , Show extraTrace ) - => [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)] -> Property + => [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters extraTrace)] -> Property ok trace = counterexample ("last few events:\n" ++ (unlines . map show) trace) $ case (lastEnvStatus, lastGovStatus) of @@ -1171,6 +1209,7 @@ prop_governor_target_root_below env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -1245,6 +1284,7 @@ prop_governor_target_established_public (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -1310,6 +1350,7 @@ prop_governor_target_established_big_ledger_peers (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -1382,6 +1423,7 @@ prop_governor_target_active_public (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -1586,6 +1628,7 @@ prop_governor_target_known_1_valid_subset (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -1662,6 +1705,7 @@ prop_governor_target_known_2_opportunity_taken (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -1820,6 +1864,7 @@ prop_governor_target_known_3_not_too_chatty (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -1832,7 +1877,8 @@ prop_governor_target_known_3_not_too_chatty (MaxTime maxTime) env = recentPeerShareActivity :: DiffTime - -> Events (TestTraceEvent extraState extraFlags extraPeers extraCounters) + -> Events (TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace) -> Signal (Maybe (Set PeerAddr), Set PeerAddr) recentPeerShareActivity d = Signal.fromChangeEvents (Nothing, Set.empty) @@ -1842,7 +1888,7 @@ recentPeerShareActivity d = where go :: Set PeerAddr -- ^ Recently shared with peers -> PSQ.OrdPSQ PeerAddr Time () -- ^ PSQ with next time to request to peers - -> [E (TestTraceEvent extraState extraFlags extraPeers extraCounters)] + -> [E (TestTraceEvent extraState extraFlags extraPeers extraCounters extraTrace)] -> [E (Maybe (Set PeerAddr), Set PeerAddr)] go !recentSet !recentPSQ txs@(E (TS t _) _ : _) | Just (k, t', _, recentPSQ') <- PSQ.minView recentPSQ @@ -2032,6 +2078,7 @@ prop_governor_target_known_4_results_used (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2114,6 +2161,7 @@ prop_governor_target_known_5_no_shrink_below (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2196,6 +2244,7 @@ prop_governor_target_known_5_no_shrink_big_ledger_peers_below (MaxTime maxTime) @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2279,6 +2328,7 @@ prop_governor_target_known_above (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2380,6 +2430,7 @@ prop_governor_target_known_big_ledger_peers_above (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2478,6 +2529,7 @@ prop_governor_target_established_below (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2586,6 +2638,7 @@ prop_governor_target_established_big_ledger_peers_below (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2696,6 +2749,7 @@ prop_governor_target_active_below (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2826,6 +2880,7 @@ prop_governor_target_active_big_ledger_peers_below (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -2925,6 +2980,7 @@ prop_governor_target_established_above (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3014,6 +3070,7 @@ prop_governor_target_established_big_ledger_peers_above (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3090,6 +3147,7 @@ prop_governor_target_active_above (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3164,6 +3222,7 @@ prop_governor_target_active_big_ledger_peers_above (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3225,6 +3284,7 @@ prop_governor_target_established_local (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3338,6 +3398,7 @@ prop_governor_target_active_local_below (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3441,6 +3502,7 @@ prop_governor_target_active_local_above (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3497,6 +3559,7 @@ prop_governor_only_bootstrap_peers_in_fallback_state env = . selectPeerSelectionTraceEvents @_ @_ @_ @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3555,6 +3618,7 @@ prop_governor_no_non_trustable_peers_before_caught_up_state env = . selectPeerSelectionTraceEvents @_ @_ @_ @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3622,6 +3686,7 @@ prop_governor_only_bootstrap_peers_in_clean_state env = . selectPeerSelectionTraceEvents @_ @_ @_ @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3725,6 +3790,7 @@ prop_governor_stops_using_bootstrap_peers env = . selectPeerSelectionTraceEvents @_ @_ @_ @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3794,6 +3860,7 @@ prop_governor_uses_ledger_peers env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3844,6 +3911,7 @@ prop_governor_association_mode env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env @@ -3974,7 +4042,11 @@ _governorFindingPublicRoots targetNumberOfRootPeers readDomains readUseBootstrap policy interfaces where - tracer' :: Tracer IO (TracePeerSelection Cardano.DebugPeerSelectionState PeerTrustable (Cardano.ExtraPeers SockAddr) SockAddr) + tracer' :: Tracer IO (TracePeerSelection Cardano.DebugPeerSelectionState + PeerTrustable + (Cardano.ExtraPeers SockAddr) + Cardano.ExtraTrace + SockAddr) tracer' = tracer tracer :: Show a => Tracer IO a @@ -4253,6 +4325,7 @@ prop_governor_repromote_delay (MaxTime maxTime) env = @PeerTrustable @(Cardano.ExtraPeers PeerAddr) @(Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + @Cardano.ExtraTrace . runGovernorInMockEnvironment $ env in property diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Gource.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Gource.hs similarity index 93% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Gource.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Gource.hs index a071720b3ea..b4b0d4b8927 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Gource.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Gource.hs @@ -3,7 +3,7 @@ {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -module Test.Ouroboros.Network.PeerSelection.Gource (gourceVisualisationScript) where +module Test.Cardano.Network.PeerSelection.Gource (gourceVisualisationScript) where import Control.Monad.Class.MonadTime.SI import Data.List (intercalate) @@ -16,9 +16,9 @@ import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPe import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Ouroboros.Network.PeerSelection.Types -import Test.Ouroboros.Network.PeerSelection.Cardano.MockEnvironment -import Test.Ouroboros.Network.PeerSelection.Instances -import Test.Ouroboros.Network.PeerSelection.Utils +import Test.Cardano.Network.PeerSelection.MockEnvironment +import Test.Cardano.Network.PeerSelection.Utils +import Test.Ouroboros.Network.PeerSelection.Instances (PeerAddr (..)) -- -- Visualisation of examples @@ -36,7 +36,7 @@ gourceVisualisationScript = . visualisationTrace visualisationTrace :: GovernorMockEnvironment - -> [(Time, TracePeerSelection () () () PeerAddr)] + -> [(Time, TracePeerSelection () () () () PeerAddr)] visualisationTrace = takeFirstNHours 24 . selectGovernorEvents @@ -44,7 +44,7 @@ visualisationTrace = . runGovernorInMockEnvironment toGourceScript :: Map PeerAddr (PeerSource, [PeerAddr]) - -> [(Time, TracePeerSelection () () () PeerAddr)] + -> [(Time, TracePeerSelection () () () () PeerAddr)] -> [GourceEntry] toGourceScript peers ((ts, TraceLocalRootPeersChanged _ new):trace) = -- link new root peers directly to the root as cold diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/Instances.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Instances.hs similarity index 95% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/Instances.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Instances.hs index e5ca61118cb..7e347836c84 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/Instances.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Instances.hs @@ -6,7 +6,7 @@ {-# OPTIONS_GHC -Wno-orphans #-} -module Test.Ouroboros.Network.PeerSelection.Cardano.Instances where +module Test.Cardano.Network.PeerSelection.Instances (ArbitraryLedgerStateJudgement (..)) where import Cardano.Network.ConsensusMode (ConsensusMode (..)) import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/LocalRootPeers.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/LocalRootPeers.hs similarity index 71% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/LocalRootPeers.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/LocalRootPeers.hs index f7263b140ce..334d0812d62 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/LocalRootPeers.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/LocalRootPeers.hs @@ -4,17 +4,18 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeApplications #-} -module Test.Ouroboros.Network.PeerSelection.Cardano.LocalRootPeers (tests) where +module Test.Cardano.Network.PeerSelection.LocalRootPeers (tests) where import Data.Map.Strict qualified as Map import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) -import Ouroboros.Network.PeerSelection.State.LocalRootPeers - (LocalRootPeers (..)) -import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers -import Test.Ouroboros.Network.PeerSelection.Cardano.Instances () +import Cardano.Network.PeerSelection.State.LocalRootPeers (LocalRootPeers) +import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers + +import Test.Cardano.Network.PeerSelection.Instances () import Test.Ouroboros.Network.PeerSelection.Instances (PeerAddr) import Test.Ouroboros.Network.PeerSelection.LocalRootPeers () + import Test.QuickCheck import Test.Tasty (TestTree, testGroup) import Test.Tasty.QuickCheck (testProperty) @@ -27,7 +28,8 @@ tests = ] ] -prop_clampToTrustable :: LocalRootPeers PeerTrustable PeerAddr -> Property +prop_clampToTrustable :: LocalRootPeers PeerTrustable PeerAddr + -> Property prop_clampToTrustable localRootPeers = let trustedPeers = LocalRootPeers.keysSet diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs similarity index 97% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs index b199ffe0c31..370e7b2dc5f 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs @@ -11,7 +11,9 @@ {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} {-# LANGUAGE TypeApplications #-} -module Test.Ouroboros.Network.PeerSelection.Cardano.MockEnvironment +-- TODO: MockEnvironment should be generalised so we can put it in +-- `ouroboros-network` and test various extensions of `PeerSelection`. +module Test.Cardano.Network.PeerSelection.MockEnvironment ( PeerGraph (..) , GovernorMockEnvironment (..) , GovernorPraosMockEnvironment (..) @@ -63,6 +65,8 @@ import Control.Monad.IOSim import Control.Tracer (Tracer (..), contramap, traceWith) import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano +import Cardano.Network.PeerSelection.Governor.Types (ExtraTrace (..), + readAssociationMode) import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy import Ouroboros.Network.PeerSelection.Governor hiding (PeerSelectionState (..)) @@ -83,6 +87,9 @@ import Test.Ouroboros.Network.PeerSelection.PeerGraph import Test.Ouroboros.Network.Utils (ShrinkCarefully, arbitrarySubset, nightlyTest, prop_shrink_nonequal, prop_shrink_valid) +import Test.Cardano.Network.PeerSelection.Instances +import Test.Cardano.Network.PeerSelection.PublicRootPeers () + import Cardano.Network.ConsensusMode import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), @@ -99,6 +106,7 @@ import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers import Cardano.Network.Types (LedgerStateJudgement (..), NumberOfBigLedgerPeers (..)) + import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..)) import Ouroboros.Network.PeerSelection.LedgerPeers import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) @@ -107,9 +115,7 @@ import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPe import Ouroboros.Network.PeerSelection.Types (PeerStatus (..)) import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingAmount, PeerSharingResult (..)) -import Test.Ouroboros.Network.PeerSelection.Cardano.Instances - (ArbitraryLedgerStateJudgement (..)) -import Test.Ouroboros.Network.PeerSelection.Cardano.PublicRootPeers () + import Test.QuickCheck import Test.Tasty (TestTree, localOption, testGroup) import Test.Tasty.QuickCheck (QuickCheckMaxSize (..), testProperty) @@ -738,9 +744,9 @@ mockPeerSelectionPolicy GovernorMockEnvironment { -- Utils for properties -- -data TestTraceEvent extraState extraFlags extraPeers extraCounters = +data TestTraceEvent extraState extraFlags extraPeers extraCounters extraTrace = GovernorDebug !(DebugPeerSelection extraState extraFlags extraPeers PeerAddr) - | GovernorEvent !(TracePeerSelection extraState extraFlags extraPeers PeerAddr) + | GovernorEvent !(TracePeerSelection extraState extraFlags extraPeers extraTrace PeerAddr) | GovernorCounters !(PeerSelectionCounters extraCounters) | GovernorAssociationMode !AssociationMode | MockEnvEvent !TraceMockEnv @@ -753,12 +759,12 @@ data TestTraceEvent extraState extraFlags extraPeers extraCounters = -- The governor debug vs other events are fully ordered. deriving Show -tracerTracePeerSelection :: Tracer (IOSim s) (TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers PeerAddr) PeerAddr) +tracerTracePeerSelection :: Tracer (IOSim s) (TracePeerSelection Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers PeerAddr) ExtraTrace PeerAddr) tracerTracePeerSelection = contramap f tracerTestTraceEvent where -- make the tracer strict - f :: TracePeerSelection extraState extraFlags extraPeers PeerAddr - -> TestTraceEvent extraState extraFlags extraPeers extraCounters + f :: TracePeerSelection extraState extraFlags extraPeers ExtraTrace PeerAddr + -> TestTraceEvent extraState extraFlags extraPeers extraCounters ExtraTrace f a@(TraceLocalRootPeersChanged !_ !_) = GovernorEvent a f a@(TraceTargetsChanged !_ !_) = GovernorEvent a f a@(TracePublicRootsRequest !_ !_) = GovernorEvent a @@ -807,10 +813,10 @@ tracerTracePeerSelection = contramap f tracerTestTraceEvent f a@(TraceDemoteBigLedgerPeersAsynchronous !_) = GovernorEvent a f a@TraceGovernorWakeup = GovernorEvent a f a@(TraceChurnWait !_) = GovernorEvent a - f a@(TraceLedgerStateJudgementChanged !_) = GovernorEvent a + f a@(ExtraTrace (TraceLedgerStateJudgementChanged !_)) = GovernorEvent a f a@TraceOnlyBootstrapPeers = GovernorEvent a f a@TraceBootstrapPeersFlagChangedWhilstInSensitiveState = GovernorEvent a - f a@(TraceUseBootstrapPeersChanged !_) = GovernorEvent a + f a@(ExtraTrace (TraceUseBootstrapPeersChanged !_)) = GovernorEvent a f a@(TraceOutboundGovernorCriticalFailure !_) = GovernorEvent a f a@(TraceDebugState !_ !_) = GovernorEvent a f a@(TraceChurnAction !_ !_ !_) = GovernorEvent a @@ -848,13 +854,18 @@ traceAssociationMode interfaces actions = Tracer $ \(TraceGovernorState _ _ st) (Cardano.bootstrapPeersFlag (Governor.extraState st)) traceWith tracerTestTraceEvent (GovernorAssociationMode associationMode) -tracerTracePeerSelectionCounters :: Tracer (IOSim s) (PeerSelectionCounters (Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr)) +tracerTracePeerSelectionCounters :: Tracer (IOSim s) (PeerSelectionCounters + (Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr)) tracerTracePeerSelectionCounters = contramap GovernorCounters tracerTestTraceEvent tracerMockEnv :: Tracer (IOSim s) TraceMockEnv tracerMockEnv = contramap MockEnvEvent tracerTestTraceEvent -tracerTestTraceEvent :: Tracer (IOSim s) (TestTraceEvent Cardano.ExtraState PeerTrustable (Cardano.ExtraPeers PeerAddr) (Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr)) +tracerTestTraceEvent :: Tracer (IOSim s) (TestTraceEvent Cardano.ExtraState + PeerTrustable + (Cardano.ExtraPeers PeerAddr) + (Cardano.ExtraPeerSelectionSetsWithSizes PeerAddr) + Cardano.ExtraTrace) tracerTestTraceEvent = dynamicTracer <> Tracer (say . show) dynamicTracer :: Typeable a => Tracer (IOSim s) a @@ -865,8 +876,9 @@ selectPeerSelectionTraceEvents , Typeable extraFlags , Typeable extraPeers , Typeable extraCounters + , Typeable extraTrace ) - => SimTrace a -> [(Time, (TestTraceEvent extraState extraFlags extraPeers extraCounters))] + => SimTrace a -> [(Time, (TestTraceEvent extraState extraFlags extraPeers extraCounters extraTrace))] selectPeerSelectionTraceEvents = go where go (SimTrace t _ _ (EventLog e) trace) @@ -887,8 +899,9 @@ selectPeerSelectionTraceEventsUntil , Typeable extraFlags , Typeable extraPeers , Typeable extraCounters + , Typeable extraTrace ) - => Time -> SimTrace a -> [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)] + => Time -> SimTrace a -> [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters extraTrace)] selectPeerSelectionTraceEventsUntil tmax = go where go (SimTrace t _ _ _ _) @@ -908,11 +921,11 @@ selectPeerSelectionTraceEventsUntil tmax = go go (TraceInternalError e) = error ("IOSim: " ++ e) go TraceLoop = error "Step time limit exceeded" -selectGovernorEvents :: [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)] - -> [(Time, TracePeerSelection extraState extraFlags extraPeers PeerAddr)] +selectGovernorEvents :: [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters extraTrace)] + -> [(Time, TracePeerSelection extraState extraFlags extraPeers extraTrace PeerAddr)] selectGovernorEvents trace = [ (t, e) | (t, GovernorEvent e) <- trace ] -selectGovernorStateEvents :: [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters)] +selectGovernorStateEvents :: [(Time, TestTraceEvent extraState extraFlags extraPeers extraCounters extraTrace)] -> [(Time, DebugPeerSelection extraState extraFlags extraPeers PeerAddr)] selectGovernorStateEvents trace = [ (t, e) | (t, GovernorDebug e) <- trace ] diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/PublicRootPeers.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/PublicRootPeers.hs similarity index 99% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/PublicRootPeers.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/PublicRootPeers.hs index 1a837bafde5..f71e3e7f02d 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Cardano/PublicRootPeers.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/PublicRootPeers.hs @@ -4,7 +4,7 @@ {-# OPTIONS_GHC -Wno-orphans #-} -module Test.Ouroboros.Network.PeerSelection.Cardano.PublicRootPeers +module Test.Cardano.Network.PeerSelection.PublicRootPeers ( arbitraryCardanoExtraPeers , tests ) where diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Utils.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Utils.hs similarity index 72% rename from ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Utils.hs rename to cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Utils.hs index dfd9bb22ad7..c6b06b7605c 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Utils.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Utils.hs @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE RankNTypes #-} -module Test.Ouroboros.Network.PeerSelection.Utils where +module Test.Cardano.Network.PeerSelection.Utils where import Control.Monad.Class.MonadTime.SI import Data.Set (Set) @@ -15,44 +15,55 @@ import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPe import Test.Ouroboros.Network.Data.Signal (Events, Signal) import Test.Ouroboros.Network.Data.Signal qualified as Signal +import Test.Ouroboros.Network.PeerSelection.Instances (PeerAddr (..)) -import Test.Ouroboros.Network.PeerSelection.Cardano.MockEnvironment hiding - (targets, tests) -import Test.Ouroboros.Network.PeerSelection.Instances +import Test.Cardano.Network.PeerSelection.MockEnvironment hiding (targets, + tests) takeFirstNHours :: DiffTime -> [(Time, a)] -> [(Time, a)] takeFirstNHours h = takeWhile (\(t,_) -> t < Time (60*60*h)) -selectEnvEvents :: Events (TestTraceEvent extraState extraFlags extraPeers extraCounters) -> Events TraceMockEnv +selectEnvEvents :: Events (TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace) + -> Events TraceMockEnv selectEnvEvents = Signal.selectEvents (\case MockEnvEvent e -> Just $! e _ -> Nothing) -selectGovEvents :: Events (TestTraceEvent extraState extraFlags extraPeers extracounters) - -> Events (TracePeerSelection extraState extraFlags extraPeers PeerAddr) +selectGovEvents :: Events (TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace) + -> Events (TracePeerSelection extraState extraFlags extraPeers + extraTrace PeerAddr) selectGovEvents = Signal.selectEvents (\case GovernorEvent e -> Just $! e _ -> Nothing) -selectGovCounters :: Events (TestTraceEvent extraState extraFlags extraPeers extraCounters) +selectGovCounters :: Events (TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace) -> Events (Governor.PeerSelectionCounters extraCounters) selectGovCounters = Signal.selectEvents (\case GovernorCounters e -> Just $! e _ -> Nothing) -selectGovAssociationMode :: Events (TestTraceEvent extraState extraFlags extraPeers extraCounters) +selectGovAssociationMode :: Events (TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace) -> Events AssociationMode selectGovAssociationMode = Signal.selectEvents (\case GovernorAssociationMode e -> Just $! e _ -> Nothing) selectGovState :: Eq a - => (forall peerconn. Governor.PeerSelectionState extraState extraFlags extraPeers PeerAddr peerconn -> a) + => (forall peerconn. + Governor.PeerSelectionState extraState extraFlags extraPeers + PeerAddr peerconn + -> a + ) -> extraState -> extraPeers - -> Events (TestTraceEvent extraState extraFlags extraPeers extraCounters) + -> Events (TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace) -> Signal a selectGovState f es ep = Signal.nub @@ -65,7 +76,8 @@ selectGovState f es ep = selectEnvTargets :: Eq a => (PeerSelectionTargets -> a) - -> Events (TestTraceEvent extraState extraFlags extraPeers extraCounters) + -> Events (TestTraceEvent extraState extraFlags extraPeers + extraCounters extraTrace) -> Signal a selectEnvTargets f = Signal.nub @@ -80,8 +92,11 @@ selectEnvTargets f = -- | filter big ledger peers -- takeBigLedgerPeers - :: (Governor.PeerSelectionState extraState extraFlags extraPeers PeerAddr peerconn -> Set PeerAddr) - -> Governor.PeerSelectionState extraState extraFlags extraPeers PeerAddr peerconn -> Set PeerAddr + :: ( Governor.PeerSelectionState extraState extraFlags extraPeers PeerAddr peerconn + -> Set PeerAddr + ) + -> Governor.PeerSelectionState extraState extraFlags extraPeers PeerAddr peerconn + -> Set PeerAddr takeBigLedgerPeers f = \st -> f st `Set.intersection` (PublicRootPeers.getBigLedgerPeers . Governor.publicRootPeers) st diff --git a/cardano-diffusion/tests/sim/Main.hs b/cardano-diffusion/tests/sim/Main.hs new file mode 100644 index 00000000000..45dfac7f251 --- /dev/null +++ b/cardano-diffusion/tests/sim/Main.hs @@ -0,0 +1,30 @@ +module Main (main) where + +import Main.Utf8 (withUtf8) +import Test.Tasty + +import Test.Cardano.Network.Diffusion.Policies qualified (tests) +import Test.Cardano.Network.Diffusion.Testnet qualified (tests) +import Test.Cardano.Network.OrphanInstances.Tests qualified (tests) +import Test.Cardano.Network.PeerSelection qualified (tests) +import Test.Cardano.Network.PeerSelection.LocalRootPeers qualified +import Test.Cardano.Network.PeerSelection.MockEnvironment qualified +import Test.Cardano.Network.PeerSelection.PublicRootPeers qualified + +main :: IO () +main = withUtf8 $ defaultMain tests + +tests :: TestTree +tests = + testGroup "cardano-diffusion-sim-tests" + [ Test.Cardano.Network.OrphanInstances.Tests.tests + + -- network logic + , Test.Cardano.Network.Diffusion.Policies.tests + , Test.Cardano.Network.PeerSelection.LocalRootPeers.tests + , Test.Cardano.Network.PeerSelection.PublicRootPeers.tests + , Test.Cardano.Network.PeerSelection.MockEnvironment.tests + , Test.Cardano.Network.PeerSelection.tests + + , Test.Cardano.Network.Diffusion.Testnet.tests + ] diff --git a/dmq-node/src/DMQ/Diffusion/Arguments.hs b/dmq-node/src/DMQ/Diffusion/Arguments.hs index 6c6f1a297df..20c882c45b3 100644 --- a/dmq-node/src/DMQ/Diffusion/Arguments.hs +++ b/dmq-node/src/DMQ/Diffusion/Arguments.hs @@ -50,7 +50,8 @@ diffusionArguments => Tracer m (NtN.HandshakeTr ntnAddr) -> Tracer m (NtC.HandshakeTr ntcAddr) -> Diffusion.Arguments - NoExtraState NoExtraDebugState NoExtraFlags NoExtraPeers NoExtraAPI NoExtraChurnArgs NoExtraCounters + NoExtraState NoExtraDebugState NoExtraFlags NoExtraPeers + NoExtraAPI NoExtraChurnArgs NoExtraCounters NoExtraTracer IOException Resolver m diff --git a/dmq-node/src/DMQ/Tracer.hs b/dmq-node/src/DMQ/Tracer.hs index a4bc3b47b2e..9643f81f71a 100644 --- a/dmq-node/src/DMQ/Tracer.hs +++ b/dmq-node/src/DMQ/Tracer.hs @@ -19,6 +19,7 @@ module DMQ.Tracer , NoExtraConfig (..) , NoExtraAPI (..) , NoExtraChurnArgs (..) + , NoExtraTracer (..) ) where import Codec.CBOR.Term (Term) @@ -103,6 +104,10 @@ instance ToJSON NoExtraDebugState where omitField _ = True data NoExtraChurnArgs = NoExtraChurnArgs data NoExtraAPI = NoExtraAPI +data NoExtraTracer = NoExtraTracer +instance ToJSON NoExtraTracer where + toJSON _ = Null + omitField _ = True instance ToJSON (Governor.PeerSelectionCounters NoExtraCounters) where toJSON Governor.PeerSelectionCounters {..} = @@ -164,6 +169,7 @@ dmqDiffusionTracers NoExtraFlags NoExtraPeers NoExtraCounters + NoExtraTracer m dmqDiffusionTracers Configuration { diff --git a/ouroboros-network/api/lib/Ouroboros/Network/BlockFetch/ConsensusInterface.hs b/ouroboros-network/api/lib/Ouroboros/Network/BlockFetch/ConsensusInterface.hs index c0f5447c50f..5b84eff0366 100644 --- a/ouroboros-network/api/lib/Ouroboros/Network/BlockFetch/ConsensusInterface.hs +++ b/ouroboros-network/api/lib/Ouroboros/Network/BlockFetch/ConsensusInterface.hs @@ -3,7 +3,6 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE RankNTypes #-} module Ouroboros.Network.BlockFetch.ConsensusInterface @@ -12,7 +11,6 @@ module Ouroboros.Network.BlockFetch.ConsensusInterface , BlockFetchConsensusInterface (..) , ChainSelStarvation (..) , ChainComparison (..) - , mkReadFetchMode -- * Utilities , WithFingerprint (..) , Fingerprint (..) @@ -22,7 +20,6 @@ module Ouroboros.Network.BlockFetch.ConsensusInterface import Control.Monad.Class.MonadSTM import Control.Monad.Class.MonadTime (UTCTime) import Control.Monad.Class.MonadTime.SI (Time) -import Data.Functor ((<&>)) import Data.Map.Strict (Map) import Data.Word (Word64) @@ -30,8 +27,6 @@ import GHC.Generics (Generic) import GHC.Stack (HasCallStack) import NoThunks.Class (NoThunks) -import Cardano.Network.ConsensusMode (ConsensusMode (..)) -import Cardano.Network.Types (LedgerStateJudgement (..)) import Ouroboros.Network.AnchoredFragment (AnchoredFragment) import Ouroboros.Network.Block import Ouroboros.Network.SizeInBytes (SizeInBytes) @@ -63,23 +58,6 @@ data PraosFetchMode = data FetchMode = FetchModeGenesis | PraosFetchMode PraosFetchMode deriving (Eq, Show) --- | Construct 'readFetchMode' for 'BlockFetchConsensusInterface' by branching --- on the 'ConsensusMode'. -mkReadFetchMode - :: Functor m - => ConsensusMode - -> m LedgerStateJudgement - -- ^ Used for 'GenesisMode'. - -> m PraosFetchMode - -- ^ Used for 'PraosMode' for backwards compatibility. - -> m FetchMode -mkReadFetchMode consensusMode getLedgerStateJudgement getFetchMode = - case consensusMode of - GenesisMode -> getLedgerStateJudgement <&> \case - YoungEnough -> PraosFetchMode FetchModeDeadline - TooOld -> FetchModeGenesis - PraosMode -> PraosFetchMode <$> getFetchMode - -- | The consensus layer functionality that the block fetch logic requires. -- -- These are provided as input to the block fetch by the consensus layer. diff --git a/ouroboros-network/api/tests/Main.hs b/ouroboros-network/api/tests/Main.hs index 4b2eeeae647..5720b7d98cd 100644 --- a/ouroboros-network/api/tests/Main.hs +++ b/ouroboros-network/api/tests/Main.hs @@ -3,9 +3,6 @@ module Main (main) where import Main.Utf8 (withUtf8) import Test.Tasty -import Test.Cardano.Network.Version qualified as Version -import Test.Cardano.Network.NodeToClient.Version qualified as NodeToClient.Version -import Test.Cardano.Network.NodeToNode.Version qualified as NodeToNode.Version import Test.Ouroboros.Network.AnchoredFragment qualified as AnchoredFragment import Test.Ouroboros.Network.Chain qualified as Chain import Test.Ouroboros.Network.PeerSelection.RelayAccessPoint qualified as RelayAccessPoint @@ -15,12 +12,9 @@ main = withUtf8 $ defaultMain tests tests :: TestTree tests = - testGroup "ouroboros-network-api" + testGroup "ouroboros-network:api" [ AnchoredFragment.tests , Chain.tests - , Version.tests - , NodeToClient.Version.tests - , NodeToNode.Version.tests , RelayAccessPoint.tests ] diff --git a/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs index 11193f96a7e..fda789bc361 100644 --- a/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs +++ b/ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Codec.hs @@ -16,9 +16,6 @@ module Ouroboros.Network.Protocol.Handshake.Codec -- ** Version data codec , VersionDataCodec (..) , cborTermVersionDataCodec - -- * NodeToNode & NodeToClient Codecs - , nodeToNodeHandshakeCodec - , nodeToClientHandshakeCodec ) where import Control.Monad (replicateM, unless) @@ -41,11 +38,6 @@ import Codec.CBOR.Encoding qualified as CBOR import Codec.CBOR.Read qualified as CBOR import Codec.CBOR.Term qualified as CBOR -import Cardano.Network.NodeToClient.Version (NodeToClientVersion, - nodeToClientVersionCodec) -import Cardano.Network.NodeToNode.Version (NodeToNodeVersion, - nodeToNodeVersionCodec) - import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Driver.Limits @@ -312,19 +304,3 @@ decodeRefuseReason versionNumberCodec = do Left e -> fail $ "decode Refused: unknonwn version: " ++ show e Right vNumber -> Refused vNumber <$> CBOR.decodeString _ -> fail $ "decode RefuseReason: unknown tag " ++ show tag - - --- | 'Handshake' codec for the @node-to-node@ protocol suite. --- -nodeToNodeHandshakeCodec :: MonadST m - => Codec (Handshake NodeToNodeVersion CBOR.Term) - CBOR.DeserialiseFailure m BL.ByteString -nodeToNodeHandshakeCodec = codecHandshake nodeToNodeVersionCodec - - --- | 'Handshake' codec for the @node-to-client@ protocol suite. --- -nodeToClientHandshakeCodec :: MonadST m - => Codec (Handshake NodeToClientVersion CBOR.Term) - CBOR.DeserialiseFailure m BL.ByteString -nodeToClientHandshakeCodec = codecHandshake nodeToClientVersionCodec diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs index dd46c7761a9..e12035dd1c2 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs @@ -95,7 +95,8 @@ runM ntcFd ntcAddr ntcVersion ntcVersionData resolver exception a extraState extraDebugState extraPeers - extraAPI extraFlags extraChurnArgs extraCounters . + extraAPI extraFlags extraChurnArgs + extraCounters extraTrace. ( Alternative (STM m) , MonadAsync m @@ -134,12 +135,12 @@ runM Tracers ntnAddr ntnVersion ntnVersionData ntcAddr ntcVersion ntcVersionData extraState extraDebugState extraFlags - extraPeers extraCounters m + extraPeers extraCounters extraTrace m -- | arguments -> Arguments extraState extraDebugState extraFlags extraPeers extraAPI extraChurnArgs - extraCounters exception resolver - m + extraCounters extraTrace + exception resolver m ntnFd ntnAddr ntnVersion ntnVersionData ntcAddr ntcVersion ntcVersionData -> -- | configuration @@ -839,6 +840,7 @@ run :: ( Monoid extraPeers extraAPI extraChurnArgs extraCounters + extraTrace exception Resolver IO @@ -861,6 +863,7 @@ run :: ( Monoid extraPeers extraFlags extraPeers extraCounters + extraTrace IO -> Configuration extraFlags diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs index 18fa655a7dc..c3eca20c470 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Configuration.hs @@ -10,15 +10,11 @@ module Ouroboros.Network.Diffusion.Configuration , defaultDeadlineChurnInterval , defaultBulkChurnInterval , BlockProducerOrRelay (..) - , defaultTxSubmissionLogicVersion -- re-exports , AcceptedConnectionsLimit (..) , DiffusionMode (..) , PeerSelectionTargets (..) , PeerSharing (..) - , ConsensusMode (..) - , TxSubmissionLogicVersion (..) - , defaultConsensusMode , defaultEgressPollInterval , deactivateTimeout , closeConnectionTimeout @@ -35,7 +31,6 @@ module Ouroboros.Network.Diffusion.Configuration import Control.Monad.Class.MonadTime.SI -import Cardano.Network.ConsensusMode import Ouroboros.Network.ConnectionManager.Core (defaultProtocolIdleTimeout, defaultResetTimeout, defaultTimeWaitTimeout) import Ouroboros.Network.Diffusion.Policies (closeConnectionTimeout, @@ -48,8 +43,6 @@ import Ouroboros.Network.PeerSharing (ps_POLICY_PEER_SHARE_MAX_PEERS, ps_POLICY_PEER_SHARE_STICKY_TIME) import Ouroboros.Network.Protocol.Handshake (handshake_QUERY_SHUTDOWN_DELAY) import Ouroboros.Network.Server.RateLimiting (AcceptedConnectionsLimit (..)) -import Ouroboros.Network.TxSubmission.Inbound.V2.Types - (TxSubmissionLogicVersion (..)) -- | Outbound governor targets -- Targets may vary depending on whether a node is operating in @@ -118,8 +111,3 @@ local_TIME_WAIT_TIMEOUT = 0 -- for tuning latency vs. network efficiency defaultEgressPollInterval :: DiffTime defaultEgressPollInterval = 0 - --- | The default logic version is the legacy one, the new one is still --- experimental. -defaultTxSubmissionLogicVersion :: TxSubmissionLogicVersion -defaultTxSubmissionLogicVersion = TxSubmissionLogicV1 diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs index b396e128b98..35923809e8b 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs @@ -127,7 +127,7 @@ instance Exception Failure data Tracers ntnAddr ntnVersion ntnVersionData ntcAddr ntcVersion ntcVersionData extraState extraDebugState - extraFlags extraPeers extraCounters m = Tracers { + extraFlags extraPeers extraCounters extraTrace m = Tracers { -- | Mux tracer dtMuxTracer :: Tracer m (Mx.WithBearer (ConnectionId ntnAddr) Mx.Trace) @@ -185,7 +185,7 @@ data Tracers ntnAddr ntnVersion ntnVersionData :: Tracer m TraceLedgerPeers , dtTracePeerSelectionTracer - :: Tracer m (TracePeerSelection extraDebugState extraFlags extraPeers ntnAddr) + :: Tracer m (TracePeerSelection extraDebugState extraFlags extraPeers extraTrace ntnAddr) , dtDebugPeerSelectionInitiatorTracer :: Tracer m (DebugPeerSelection extraState extraFlags extraPeers ntnAddr) @@ -250,7 +250,9 @@ nullTracers :: Applicative m => Tracers ntnAddr ntnVersion ntnVersionData ntcAddr ntcVersion ntcVersionData extraState extraDebugState - extraFlags extraPeers extraCounters m + extraFlags extraPeers + extraCounters extraTrace + m nullTracers = Tracers { dtMuxTracer = nullTracer , dtChannelTracer = nullTracer @@ -285,8 +287,8 @@ nullTracers = Tracers { -- diffusion layer. These differ from -- data Arguments extraState extraDebugState extraFlags extraPeers - extraAPI extraChurnArgs extraCounters exception - resolver m + extraAPI extraChurnArgs extraCounters extraTrace + exception resolver m ntnFd ntnAddr ntnVersion ntnVersionData ntcAddr ntcVersion ntcVersionData = Arguments { @@ -350,7 +352,7 @@ data Arguments extraState extraDebugState extraFlags extraPeers :: forall muxMode responderCtx bytes a b . PeerSelectionGovernorArgs extraState extraDebugState extraFlags extraPeers - extraAPI extraCounters + extraAPI extraCounters extraTrace ntnAddr (PeerConnectionHandle muxMode responderCtx ntnAddr ntnVersionData bytes m a b) @@ -400,6 +402,7 @@ data Arguments extraState extraDebugState extraFlags extraPeers extraPeers extraAPI extraCounters + extraTrace ntnAddr -> m Void diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs index 20b399d4fe6..c50a4f95895 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs @@ -47,8 +47,8 @@ data ChurnCounters = ChurnCounter ChurnAction Int -- | Record of arguments for peer churn governor -- -data PeerChurnArgs m extraArgs extraDebugState extraFlags extraPeers extraAPI extraCounters peeraddr = PeerChurnArgs { - pcaPeerSelectionTracer :: Tracer m (TracePeerSelection extraDebugState extraFlags extraPeers peeraddr), +data PeerChurnArgs m extraArgs extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace peeraddr = PeerChurnArgs { + pcaPeerSelectionTracer :: Tracer m (TracePeerSelection extraDebugState extraFlags extraPeers extraTrace peeraddr), pcaChurnTracer :: Tracer m ChurnCounters, pcaDeadlineInterval :: DiffTime, pcaBulkInterval :: DiffTime, @@ -72,13 +72,13 @@ data PeerChurnArgs m extraArgs extraDebugState extraFlags extraPeers extraAPI ex -- On startup the churn governor gives a head start to local root peers over -- root peers. -- -peerChurnGovernor :: forall m extraArgs extraDebugState extraFlags extraPeers extraAPI extraCounters peeraddr. +peerChurnGovernor :: forall m extraArgs extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace peeraddr. ( MonadDelay m , Alternative (STM m) , MonadTimer m , MonadCatch m ) - => PeerChurnArgs m extraArgs extraDebugState extraFlags extraPeers extraAPI extraCounters peeraddr + => PeerChurnArgs m extraArgs extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace peeraddr -> m Void peerChurnGovernor PeerChurnArgs { diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs index 6b7b9e7feab..049604acbe7 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs @@ -28,7 +28,6 @@ module Ouroboros.Network.PeerSelection.Governor , ChurnAction (..) , DebugPeerSelection (..) , AssociationMode (..) - , readAssociationMode , DebugPeerSelectionState (..) , peerSelectionGovernor -- * Internals exported for testing @@ -65,7 +64,6 @@ import Control.Monad.Class.MonadTimer.SI import Control.Tracer (Tracer (..), traceWith) import System.Random -import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) import Ouroboros.Network.PeerSelection.Governor.ActivePeers qualified as ActivePeers import Ouroboros.Network.PeerSelection.Governor.BigLedgerPeers qualified as BigLedgerPeers import Ouroboros.Network.PeerSelection.Governor.EstablishedPeers qualified as EstablishedPeers @@ -73,7 +71,6 @@ import Ouroboros.Network.PeerSelection.Governor.KnownPeers qualified as KnownPee import Ouroboros.Network.PeerSelection.Governor.Monitor qualified as Monitor import Ouroboros.Network.PeerSelection.Governor.RootPeers qualified as RootPeers import Ouroboros.Network.PeerSelection.Governor.Types -import Ouroboros.Network.PeerSelection.LedgerPeers.Type (UseLedgerPeers (..)) import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Ouroboros.Network.PeerSelection.State.EstablishedPeers qualified as EstablishedPeers import Ouroboros.Network.PeerSelection.State.KnownPeers qualified as KnownPeers @@ -465,11 +462,11 @@ peerSelectionGovernor :: ( Alternative (STM m) , Semigroup extraPeers , Eq extraFlags ) - => Tracer m (TracePeerSelection extraDebugState extraFlags extraPeers peeraddr) + => Tracer m (TracePeerSelection extraDebugState extraFlags extraPeers extraTrace peeraddr) -> Tracer m (DebugPeerSelection extraState extraFlags extraPeers peeraddr) -> Tracer m (PeerSelectionCounters extraCounters) -> PeerSelectionGovernorArgs - extraState extraDebugState extraFlags extraPeers extraAPI extraCounters + extraState extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace peeraddr peerconn exception m -> StdGen -> extraState @@ -511,7 +508,8 @@ peerSelectionGovernor tracer debugTracer countersTracer peerSelectionArgs fuzzRn -- In each case we trace the action, update the state and execute the -- action asynchronously. -- -peerSelectionGovernorLoop :: forall m extraState extraDebugState extraFlags extraPeers extraAPI extraCounters exception peeraddr peerconn. +peerSelectionGovernorLoop :: forall m extraState extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace + exception peeraddr peerconn. ( Alternative (STM m) , MonadAsync m , MonadDelay m @@ -525,11 +523,11 @@ peerSelectionGovernorLoop :: forall m extraState extraDebugState extraFlags extr , Semigroup extraPeers , Eq extraFlags ) - => Tracer m (TracePeerSelection extraDebugState extraFlags extraPeers peeraddr) + => Tracer m (TracePeerSelection extraDebugState extraFlags extraPeers extraTrace peeraddr) -> Tracer m (DebugPeerSelection extraState extraFlags extraPeers peeraddr) -> Tracer m (PeerSelectionCounters extraCounters) -> PeerSelectionGovernorArgs - extraState extraDebugState extraFlags extraPeers extraAPI extraCounters + extraState extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace peeraddr peerconn exception m -> PeerSelectionActions extraState extraFlags extraPeers extraAPI extraCounters @@ -538,7 +536,7 @@ peerSelectionGovernorLoop :: forall m extraState extraDebugState extraFlags extr -> PeerSelectionInterfaces extraState extraFlags extraPeers extraCounters peeraddr peerconn m - -> JobPool () m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> JobPool () m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn -> m Void peerSelectionGovernorLoop tracer @@ -644,7 +642,7 @@ peerSelectionGovernorLoop tracer evalGuardedDecisions :: Time -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> m (TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> m (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) evalGuardedDecisions blockedAt st = do inboundPeers <- readInboundPeers actions case guardedDecisions blockedAt st inboundPeers of @@ -669,12 +667,12 @@ peerSelectionGovernorLoop tracer guardedDecisions :: Time -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn -> Map peeraddr PeerSharing - -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) guardedDecisions blockedAt st inboundPeers = -- All the alternative potentially-blocking decisions. - -- Make sure preBlocking set is in the right place - preBlocking policy actions st + -- Make sure preBlocking set is in the right place + preBlocking policy actions st <> Monitor.connections actions st <> Monitor.jobs jobPool st @@ -731,37 +729,10 @@ peerSelectionGovernorLoop tracer wakeupDecision :: PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn + -> TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn wakeupDecision st _now = Decision { decisionTrace = [TraceGovernorWakeup], decisionState = st { stdGen = fst (split (stdGen st)) } , decisionJobs = [] } - - --- | Classify if a node is in promiscuous mode. --- --- A node is not in promiscuous mode only if: it doesn't use ledger peers, peer --- sharing, the set of bootstrap peers is empty. --- -readAssociationMode - :: MonadSTM m - => STM m UseLedgerPeers - -> PeerSharing - -> UseBootstrapPeers - -> STM m AssociationMode -readAssociationMode - readUseLedgerPeers - peerSharing - useBootstrapPeers - = - do useLedgerPeers <- readUseLedgerPeers - pure $ - case (useLedgerPeers, peerSharing, useBootstrapPeers) of - (DontUseLedgerPeers, PeerSharingDisabled, DontUseBootstrapPeers) - -> LocalRootsOnly - (DontUseLedgerPeers, PeerSharingDisabled, UseBootstrapPeers config) - | null config - -> LocalRootsOnly - _ -> Unrestricted diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs index 1473ed86665..e68f397bbb0 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/ActivePeers.hs @@ -45,7 +45,7 @@ import Ouroboros.Network.PeerSelection.Types (PeerStatus (..), -- belowTarget :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( Alternative (STM m) , MonadDelay m , MonadSTM m @@ -73,6 +73,7 @@ belowTarget extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -87,7 +88,8 @@ belowTarget enableAction = belowTargetBigLedgerPeers enableAction -- state) then this monitoring action will be disabled. -- belowTargetBigLedgerPeers - :: forall extraState extraDebugState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m. + :: forall extraState extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace + peeraddr peerconn m. ( MonadDelay m , MonadSTM m , Ord peeraddr @@ -114,6 +116,7 @@ belowTargetBigLedgerPeers extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -198,7 +201,7 @@ belowTargetBigLedgerPeers enableAction belowTargetLocal :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadDelay m , MonadSTM m , Ord peeraddr @@ -218,6 +221,7 @@ belowTargetLocal extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -320,7 +324,7 @@ belowTargetLocal actions@PeerSelectionActions { belowTargetOther :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadDelay m , MonadSTM m , Ord peeraddr @@ -340,6 +344,7 @@ belowTargetOther extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -421,7 +426,7 @@ belowTargetOther actions@PeerSelectionActions { jobPromoteWarmPeer :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadDelay m , Ord peeraddr ) @@ -438,8 +443,8 @@ jobPromoteWarmPeer -> peeraddr -> IsBigLedgerPeer -> peerconn - -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr - peerconn) + -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace + peeraddr peerconn) jobPromoteWarmPeer PeerSelectionActions{ peerStateActions = PeerStateActions { activatePeerConnection, @@ -451,7 +456,7 @@ jobPromoteWarmPeer PeerSelectionActions{ peerStateActions = where handler :: SomeException -> m (Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) handler e = do -- We wait here, not to avoid race conditions or broken locking, this is -- just a very simple back-off strategy. For cold -> warm failures we use @@ -541,7 +546,7 @@ jobPromoteWarmPeer PeerSelectionActions{ peerStateActions = } - job :: m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + job :: m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) job = do activatePeerConnection isBigLedgerPeer peerconn return $ Completion $ \st@PeerSelectionState { @@ -602,7 +607,7 @@ jobPromoteWarmPeer PeerSelectionActions{ peerStateActions = -- aboveTarget :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( Alternative (STM m) , MonadTimer m , Ord peeraddr @@ -622,6 +627,7 @@ aboveTarget extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -635,7 +641,7 @@ aboveTarget = aboveTargetBigLedgerPeers aboveTargetBigLedgerPeers :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadTimer m , Ord peeraddr ) @@ -653,6 +659,7 @@ aboveTargetBigLedgerPeers extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -732,7 +739,7 @@ aboveTargetBigLedgerPeers actions@PeerSelectionActions { aboveTargetLocal :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadTimer m , Ord peeraddr , HasCallStack @@ -751,6 +758,7 @@ aboveTargetLocal extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -836,7 +844,7 @@ aboveTargetLocal actions@PeerSelectionActions { aboveTargetOther :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadTimer m , Ord peeraddr , HasCallStack @@ -855,6 +863,7 @@ aboveTargetOther extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -935,7 +944,8 @@ aboveTargetOther actions@PeerSelectionActions { jobDemoteActivePeer - :: forall extraState extraDebugState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m. + :: forall extraState extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace + peeraddr peerconn m. ( MonadTimer m , Ord peeraddr ) @@ -950,14 +960,14 @@ jobDemoteActivePeer m -> peeraddr -> peerconn - -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr - peerconn) + -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace + peeraddr peerconn) jobDemoteActivePeer PeerSelectionActions{peerStateActions = PeerStateActions {deactivatePeerConnection, monitorPeerConnection}} peeraddr peerconn = Job job handler () "demoteActivePeer" where - handler :: SomeException -> m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + handler :: SomeException -> m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) handler e = do -- cf. issue #5111 - we wait for the connection to be forgotten by the CM -- before we return. Otherwise, if the same peer is promoted too quickly by @@ -1016,7 +1026,7 @@ jobDemoteActivePeer PeerSelectionActions{peerStateActions = PeerStateActions {de decisionJobs = [] } - job :: m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + job :: m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) job = do deactivatePeerConnection peerconn return . Completion $ \st@PeerSelectionState { diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs index 42b0d239d63..ea23f6ff434 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/BigLedgerPeers.hs @@ -56,7 +56,7 @@ belowTarget peerconn -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) belowTarget enableAction actions@PeerSelectionActions { extraPeersAPI = PublicExtraPeersAPI { @@ -107,7 +107,7 @@ belowTarget enableAction jobReqBigLedgerPeers :: forall m extraState extraDebugState extraFlags extraAPI extraPeers - extraCounters peeraddr peerconn. + extraCounters extraTrace peeraddr peerconn. ( MonadSTM m , Ord peeraddr , Semigroup extraPeers @@ -123,8 +123,8 @@ jobReqBigLedgerPeers m -> StdGen -> Int - -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr - peerconn) + -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace + peeraddr peerconn) jobReqBigLedgerPeers PeerSelectionActions { extraPeersAPI = PublicExtraPeersAPI { extraPeersToSet, @@ -137,7 +137,7 @@ jobReqBigLedgerPeers PeerSelectionActions { numExtraAllowed = Job job (return . handler) () "reqBigLedgerPeers" where - handler :: SomeException -> Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn + handler :: SomeException -> Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn handler e = Completion $ \st now -> -- This is a failure, so move the backoff counter one in the failure @@ -165,7 +165,7 @@ jobReqBigLedgerPeers PeerSelectionActions { decisionJobs = [] } - job :: m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + job :: m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) job = do (results, ttl) <- requestPublicRootPeers BigLedgerPeers rng numExtraAllowed return $ Completion $ \st now -> @@ -232,7 +232,7 @@ jobReqBigLedgerPeers PeerSelectionActions { aboveTarget :: forall m extraState extraDebugState extraFlags extraAPI extraPeers - extraCounters peeraddr peerconn. + extraCounters extraTrace peeraddr peerconn. ( Alternative (STM m) , MonadSTM m , Ord peeraddr @@ -252,6 +252,7 @@ aboveTarget extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs index fecf186f5d8..a457c429335 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/EstablishedPeers.hs @@ -62,7 +62,7 @@ import Ouroboros.Network.PeerSelection.Types (PeerStatus (..), -- belowTarget :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( Alternative (STM m) , MonadSTM m , Ord peeraddr @@ -88,6 +88,7 @@ belowTarget extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -102,7 +103,7 @@ belowTarget enableAction = -- belowTargetLocal :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadSTM m , Ord peeraddr , HasCallStack @@ -116,6 +117,7 @@ belowTargetLocal extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -220,7 +222,7 @@ belowTargetLocal actions@PeerSelectionActions { belowTargetOther :: forall extraState extraDebugState extraFlags extraPeers - extraAPI extraCounters peeraddr peerconn m. + extraAPI extraCounters extraTrace peeraddr peerconn m. ( MonadSTM m , Ord peeraddr , HasCallStack @@ -239,6 +241,7 @@ belowTargetOther extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -328,7 +331,7 @@ belowTargetOther actions@PeerSelectionActions { -- belowTargetBigLedgerPeers :: forall extraState extraDebugState extraFlags extraPeers - extraAPI extraCounters peeraddr peerconn m. + extraAPI extraCounters extraTrace peeraddr peerconn m. ( MonadSTM m , Ord peeraddr , HasCallStack @@ -355,6 +358,7 @@ belowTargetBigLedgerPeers extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -453,7 +457,7 @@ maxColdPeerRetryBackoff = 5 jobPromoteColdPeer :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( Monad m , Ord peeraddr ) @@ -471,7 +475,7 @@ jobPromoteColdPeer -> IsBigLedgerPeer -> DiffusionMode -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) jobPromoteColdPeer PeerSelectionActions { peerStateActions = PeerStateActions {establishPeerConnection}, peerConnToPeerSharing, @@ -486,7 +490,7 @@ jobPromoteColdPeer PeerSelectionActions { where handler :: SomeException -> m (Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) handler e = return $ Completion $ \st@PeerSelectionState { publicRootPeers, @@ -538,7 +542,7 @@ jobPromoteColdPeer PeerSelectionActions { decisionJobs = [] } - job :: m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + job :: m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) job = do --TODO: decide if we should do timeouts here or if we should make that -- the responsibility of establishPeerConnection @@ -617,7 +621,7 @@ jobPromoteColdPeer PeerSelectionActions { -- aboveTarget :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( Alternative (STM m) , MonadThrow m , MonadTimer m @@ -637,6 +641,7 @@ aboveTarget extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -644,7 +649,7 @@ aboveTarget = aboveTargetBigLedgerPeers <> aboveTargetOther aboveTargetOther :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadThrow m , MonadTimer m , Ord peeraddr @@ -664,6 +669,7 @@ aboveTargetOther extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -758,7 +764,7 @@ aboveTargetOther actions@PeerSelectionActions { aboveTargetBigLedgerPeers :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadThrow m , MonadTimer m , Ord peeraddr @@ -778,6 +784,7 @@ aboveTargetBigLedgerPeers extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m @@ -864,7 +871,7 @@ aboveTargetBigLedgerPeers actions@PeerSelectionActions { jobDemoteEstablishedPeer :: forall extraState extraDebugState extraFlags extraPeers extraAPI - extraCounters peeraddr peerconn m. + extraCounters extraTrace peeraddr peerconn m. ( MonadThrow m , MonadTimer m , Ord peeraddr @@ -881,7 +888,7 @@ jobDemoteEstablishedPeer -> peeraddr -> peerconn -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) jobDemoteEstablishedPeer PeerSelectionActions { peerStateActions = PeerStateActions {closePeerConnection, @@ -892,7 +899,7 @@ jobDemoteEstablishedPeer PeerSelectionActions { where handler :: SomeException -> m (Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) handler e = do -- cf. issue #5111 - we wait for the connection to be forgotten by the CM -- before we return. Otherwise, if the same peer is promoted too quickly by @@ -948,7 +955,7 @@ jobDemoteEstablishedPeer PeerSelectionActions { decisionJobs = [] } - job :: m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + job :: m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) job = do closePeerConnection peerconn -- cf. issue #5111 - we wait for the connection to be forgotten by the CM diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs index 6249908caa6..da4967b7f3a 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/KnownPeers.hs @@ -2,7 +2,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} module Ouroboros.Network.PeerSelection.Governor.KnownPeers @@ -63,7 +62,7 @@ belowTarget -> PeerSelectionActions extraState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m -> Time -- ^ blocked at -> Map peeraddr PeerSharing - -> MkGuardedDecision extraState extraDebugState extraFlags extraPeers peeraddr peerconn m + -> MkGuardedDecision extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn m belowTarget enableAction actions@PeerSelectionActions { peerSharing, @@ -243,7 +242,7 @@ belowTarget enableAction -- is used. jobPeerShare :: forall m extraState extraDebugState extraFlags extraPeers - extraAPI extraCounters peeraddr peerconn. + extraAPI extraCounters extraTrace peeraddr peerconn. (MonadAsync m, MonadTimer m, Ord peeraddr, Hashable peeraddr) => PeerSelectionActions extraState @@ -260,7 +259,7 @@ jobPeerShare -> PeerSharingAmount -> [peeraddr] -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) jobPeerShare PeerSelectionActions{requestPeerShare} PeerSelectionPolicy { policyPeerShareBatchWaitTime , policyPeerShareOverallTimeout @@ -279,7 +278,7 @@ jobPeerShare PeerSelectionActions{requestPeerShare} sortBy (\a b -> compare (hashWithSalt salt a) (hashWithSalt salt b)) addrs - handler :: [peeraddr] -> SomeException -> m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + handler :: [peeraddr] -> SomeException -> m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) handler peers e = return $ Completion $ \st _ -> Decision { decisionTrace = [TracePeerShareResults [ (p, Left e) | p <- peers ]], @@ -290,7 +289,7 @@ jobPeerShare PeerSelectionActions{requestPeerShare} decisionJobs = [] } - jobPhase1 :: [peeraddr] -> m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + jobPhase1 :: [peeraddr] -> m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) jobPhase1 peers = do -- In the typical case, where most requests return within a short -- timeout we want to collect all the responses into a batch and @@ -385,7 +384,7 @@ jobPeerShare PeerSelectionActions{requestPeerShare} } jobPhase2 :: Int -> [peeraddr] -> [Async m (PeerSharingResult peeraddr)] - -> m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) jobPhase2 maxRemaining peers peerShares = do -- Wait again, for all remaining to finish or a timeout. @@ -474,6 +473,7 @@ aboveTarget extraDebugState extraFlags extraPeers + extraTrace peeraddr peerconn m diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Monitor.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Monitor.hs index ae5c0268679..652c5b7df07 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Monitor.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Monitor.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -59,7 +58,7 @@ import Ouroboros.Network.PeerSelection.Types targetPeers :: (MonadSTM m, Ord peeraddr) => PeerSelectionActions extraState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) targetPeers PeerSelectionActions{ readPeerSelectionTargets, extraPeersAPI } @@ -102,9 +101,9 @@ targetPeers PeerSelectionActions{ readPeerSelectionTargets, -- | Await for the first result from 'JobPool' and return its 'Decision'. -- jobs :: MonadSTM m - => JobPool () m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + => JobPool () m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) jobs jobPool st = -- This case is simple because the job pool returns a 'Completion' which is -- just a function from the current state to a new 'Decision'. @@ -115,11 +114,12 @@ jobs jobPool st = -- | Monitor connections. -- -connections :: forall m extraState extraDebugState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn. +connections :: forall m extraState extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace + peeraddr peerconn. (MonadSTM m, Ord peeraddr) => PeerSelectionActions extraState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) connections PeerSelectionActions{ peerStateActions = PeerStateActions {monitorPeerConnection} } @@ -310,11 +310,12 @@ connections PeerSelectionActions{ -- | Monitor local roots using 'readLocalRootPeers' 'STM' action. -- -localRoots :: forall extraState extraDebugState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m. +localRoots :: forall extraState extraDebugState extraFlags extraPeers extraAPI extraCounters extraTrace + peeraddr peerconn m. (MonadTimer m, Ord peeraddr, Eq extraFlags) => PeerSelectionActions extraState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) localRoots actions@PeerSelectionActions{ readLocalRootPeers , extraPeersAPI = PublicExtraPeersAPI { differenceExtraPeers @@ -416,7 +417,7 @@ jobVerifyPeerSnapshot :: MonadSTM m => SRVPrefix -> LedgerPeerSnapshot -> LedgerPeersConsensusInterface extraAPI m - -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) jobVerifyPeerSnapshot srvPrefix ledgerPeerSnapshot ledgerCtx@LedgerPeersConsensusInterface { lpGetLatestSlot } @@ -448,7 +449,7 @@ ledgerPeerSnapshotChange :: (MonadSTM m) => (extraState -> extraState) -> PeerSelectionActions extraState extraFlags extraPeers extraAPI extraCounters peeraddr peerconn m -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) ledgerPeerSnapshotChange extraStateChange PeerSelectionActions { readLedgerPeerSnapshot diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs index 9bd5e50ae63..831e147b9b9 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/RootPeers.hs @@ -44,7 +44,7 @@ belowTarget -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) belowTarget actions@PeerSelectionActions { extraPeersAPI = PublicExtraPeersAPI { extraPeersToSet @@ -98,7 +98,7 @@ belowTarget actions@PeerSelectionActions { jobReqPublicRootPeers :: forall m extraState extraDebugState extraFlags extraPeers - extraAPI extraCounters peeraddr peerconn. + extraAPI extraCounters extraTrace peeraddr peerconn. ( MonadSTM m , Ord peeraddr , Semigroup extraPeers @@ -115,7 +115,7 @@ jobReqPublicRootPeers -> StdGen -> Int -> Job () m (Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) jobReqPublicRootPeers PeerSelectionActions{ requestPublicRootPeers, extraPeersAPI = PublicExtraPeersAPI { differenceExtraPeers, @@ -130,7 +130,7 @@ jobReqPublicRootPeers PeerSelectionActions{ requestPublicRootPeers, where handler :: SomeException -> Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn + extraTrace peeraddr peerconn handler e = Completion $ \st now -> -- This is a failure, so move the backoff counter one in the failure @@ -159,7 +159,7 @@ jobReqPublicRootPeers PeerSelectionActions{ requestPublicRootPeers, } job :: m (Completion m extraState extraDebugState extraFlags extraPeers - peeraddr peerconn) + extraTrace peeraddr peerconn) job = do (results, ttl) <- requestPublicRootPeers AllLedgerPeers rng numExtraAllowed return $ Completion $ \st now -> diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs index f02609d664d..f220dddaf77 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs @@ -25,11 +25,9 @@ module Ouroboros.Network.PeerSelection.Governor.Types , sanePeerSelectionTargets , PickPolicy , c_PEER_DEMOTION_TIMEOUT - -- ** Cardano Node specific functions , pickPeers , pickUnknownPeers - -- * P2P governor low level API -- These records are needed to run the peer selection. , PeerStateActions (..) @@ -54,68 +52,13 @@ module Ouroboros.Network.PeerSelection.Governor.Types , TimedDecision , MkGuardedDecision , Completion (..) - , PeerSelectionView - ( .., - PeerSelectionCounters, - numberOfRootPeers, - - numberOfKnownPeers, - numberOfAvailableToConnectPeers, - numberOfColdPeersPromotions, - numberOfEstablishedPeers, - numberOfWarmPeersDemotions, - numberOfWarmPeersPromotions, - numberOfActivePeers, - numberOfActivePeersDemotions, - - numberOfKnownBigLedgerPeers, - numberOfAvailableToConnectBigLedgerPeers, - numberOfColdBigLedgerPeersPromotions, - numberOfEstablishedBigLedgerPeers, - numberOfWarmBigLedgerPeersDemotions, - numberOfWarmBigLedgerPeersPromotions, - numberOfActiveBigLedgerPeers, - numberOfActiveBigLedgerPeersDemotions, - - numberOfKnownLocalRootPeers, - numberOfAvailableToConnectLocalRootPeers, - numberOfColdLocalRootPeersPromotions, - numberOfEstablishedLocalRootPeers, - numberOfWarmLocalRootPeersPromotions, - numberOfActiveLocalRootPeers, - numberOfActiveLocalRootPeersDemotions, - - numberOfKnownNonRootPeers, - numberOfColdNonRootPeersPromotions, - numberOfEstablishedNonRootPeers, - numberOfWarmNonRootPeersDemotions, - numberOfWarmNonRootPeersPromotions, - numberOfActiveNonRootPeers, - numberOfActiveNonRootPeersDemotions, - - extraCounters, - - PeerSelectionCountersHWC, - numberOfColdPeers, - numberOfWarmPeers, - numberOfHotPeers, - - numberOfColdBigLedgerPeers, - numberOfWarmBigLedgerPeers, - numberOfHotBigLedgerPeers, - - numberOfColdLocalRootPeers, - numberOfWarmLocalRootPeers, - numberOfHotLocalRootPeers - ) + , PeerSelectionView (.., PeerSelectionCounters, numberOfRootPeers, numberOfKnownPeers, numberOfAvailableToConnectPeers, numberOfColdPeersPromotions, numberOfEstablishedPeers, numberOfWarmPeersDemotions, numberOfWarmPeersPromotions, numberOfActivePeers, numberOfActivePeersDemotions, numberOfKnownBigLedgerPeers, numberOfAvailableToConnectBigLedgerPeers, numberOfColdBigLedgerPeersPromotions, numberOfEstablishedBigLedgerPeers, numberOfWarmBigLedgerPeersDemotions, numberOfWarmBigLedgerPeersPromotions, numberOfActiveBigLedgerPeers, numberOfActiveBigLedgerPeersDemotions, numberOfKnownLocalRootPeers, numberOfAvailableToConnectLocalRootPeers, numberOfColdLocalRootPeersPromotions, numberOfEstablishedLocalRootPeers, numberOfWarmLocalRootPeersPromotions, numberOfActiveLocalRootPeers, numberOfActiveLocalRootPeersDemotions, numberOfKnownNonRootPeers, numberOfColdNonRootPeersPromotions, numberOfEstablishedNonRootPeers, numberOfWarmNonRootPeersDemotions, numberOfWarmNonRootPeersPromotions, numberOfActiveNonRootPeers, numberOfActiveNonRootPeersDemotions, extraCounters, PeerSelectionCountersHWC, numberOfColdPeers, numberOfWarmPeers, numberOfHotPeers, numberOfColdBigLedgerPeers, numberOfWarmBigLedgerPeers, numberOfHotBigLedgerPeers, numberOfColdLocalRootPeers, numberOfWarmLocalRootPeers, numberOfHotLocalRootPeers) , PeerSelectionCounters , PeerSelectionSetsWithSizes , emptyPeerSelectionCounters - -- ** Cardano Node specific functions , peerSelectionStateToCounters , peerSelectionStateToView - -- * Peer Sharing Auxiliary data type , PeerSharingResult (..) -- * Traces @@ -146,7 +89,6 @@ import Control.Monad.Class.MonadTime.SI import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy -import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) import Ouroboros.Network.PeerSelection.LedgerPeers.Type import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing) import Ouroboros.Network.PeerSelection.PublicRootPeers (PublicRootPeers) @@ -162,7 +104,6 @@ import Ouroboros.Network.PeerSelection.Types (PeerSource (..), PeerStatus (PeerHot, PeerWarm), PublicExtraPeersAPI) import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingAmount, PeerSharingResult (..)) -import Cardano.Network.Types (LedgerStateJudgement (..)) -- | A peer pick policy is an action that picks a subset of elements from a -- map of peers. @@ -480,7 +421,7 @@ data PeerStateActions peeraddr peerconn m = PeerStateActions { -- Extra Guarded Decisions -- type MonitoringAction extraState extraDebugState extraFlags - extraPeers extraAPI extraCounters peeraddr peerconn m = + extraPeers extraAPI extraCounters extraTrace peeraddr peerconn m = PeerSelectionPolicy peeraddr m -> PeerSelectionActions extraState @@ -498,11 +439,11 @@ type MonitoringAction extraState extraDebugState extraFlags peeraddr peerconn -> Guarded (STM m) - (TimedDecision m extraState extraDebugState extraFlags extraPeers + (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) data ExtraGuardedDecisions extraState extraDebugState extraFlags - extraPeers extraAPI extraCounters peeraddr peerconn m = + extraPeers extraAPI extraCounters extraTrace peeraddr peerconn m = ExtraGuardedDecisions { -- | This guarded decision will come before all default possibly @@ -512,7 +453,7 @@ data ExtraGuardedDecisions extraState extraDebugState extraFlags -- Note that this action should be blocking. preBlocking :: MonitoringAction extraState extraDebugState extraFlags - extraPeers extraAPI extraCounters peeraddr peerconn m + extraPeers extraAPI extraCounters extraTrace peeraddr peerconn m -- | This guarded decision will come after all possibly preBlocking -- and default blocking decisions. The order matters; first decisions @@ -521,7 +462,7 @@ data ExtraGuardedDecisions extraState extraDebugState extraFlags -- Note that these actions can be either blocking or non-blocking. , postBlocking :: MonitoringAction extraState extraDebugState extraFlags - extraPeers extraAPI extraCounters peeraddr peerconn m + extraPeers extraAPI extraCounters extraTrace peeraddr peerconn m -- | This guarded decision will come before all default non-blocking -- decisions. The order matters; first decisions have priority over @@ -530,7 +471,7 @@ data ExtraGuardedDecisions extraState extraDebugState extraFlags -- Note that these actions should not be blocking. , postNonBlocking :: MonitoringAction extraState extraDebugState extraFlags - extraPeers extraAPI extraCounters peeraddr peerconn m + extraPeers extraAPI extraCounters extraTrace peeraddr peerconn m -- | This action is necessary to the well functioning of the Outbound -- Governor. In particular this action should monitor 'PeerSelectionTargets', @@ -545,7 +486,7 @@ data ExtraGuardedDecisions extraState extraDebugState extraFlags , customTargetsAction :: Maybe (MonitoringAction extraState extraDebugState extraFlags extraPeers extraAPI extraCounters - peeraddr peerconn m) + extraTrace peeraddr peerconn m) -- | This action is necessary to the well functioning of the Outbound -- Governor. In particular this action should monitor Monitor local roots @@ -560,7 +501,7 @@ data ExtraGuardedDecisions extraState extraDebugState extraFlags , customLocalRootsAction :: Maybe (MonitoringAction extraState extraDebugState extraFlags extraPeers extraAPI extraCounters - peeraddr peerconn m) + extraTrace peeraddr peerconn m) -- | This enables third party users to add extra guards to the following monitoring -- actions that make progress towards targets: @@ -590,7 +531,7 @@ data ExtraGuardedDecisions extraState extraDebugState extraFlags -- data PeerSelectionGovernorArgs extraState extraDebugState extraFlags - extraPeers extraAPI extraCounters peeraddr peerconn + extraPeers extraAPI extraCounters extraTrace peeraddr peerconn exception m = PeerSelectionGovernorArgs { abortGovernor @@ -605,7 +546,7 @@ data PeerSelectionGovernorArgs extraState extraDebugState extraFlags -> STM m () , extraDecisions :: ExtraGuardedDecisions extraState extraDebugState extraFlags - extraPeers extraAPI extraCounters peeraddr peerconn m + extraPeers extraAPI extraCounters extraTrace peeraddr peerconn m } ----------------------- @@ -929,18 +870,18 @@ data PeerSelectionView extraViews a = PeerSelectionView { -- Non-Root Peers -- - viewKnownNonRootPeers :: a, + viewKnownNonRootPeers :: a, -- ^ number of known non root peers. These are mostly peers received -- through peer sharing (or light peer sharing); but also will contains -- peers which used to be local roots after a reconfiguration. - viewColdNonRootPeersPromotions :: a, - viewEstablishedNonRootPeers :: a, - viewWarmNonRootPeersDemotions :: a, - viewWarmNonRootPeersPromotions :: a, - viewActiveNonRootPeers :: a, - viewActiveNonRootPeersDemotions :: a, - - viewExtraViews :: extraViews + viewColdNonRootPeersPromotions :: a, + viewEstablishedNonRootPeers :: a, + viewWarmNonRootPeersDemotions :: a, + viewWarmNonRootPeersPromotions :: a, + viewActiveNonRootPeers :: a, + viewActiveNonRootPeersDemotions :: a, + + viewExtraViews :: extraViews } deriving (Eq, Functor, Show) @@ -1632,9 +1573,9 @@ instance Alternative m => Monoid (Guarded m a) where mappend = (<>) -data Decision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn = Decision { +data Decision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn = Decision { -- | A trace event to classify the decision and action - decisionTrace :: [TracePeerSelection extraDebugState extraFlags extraPeers peeraddr], + decisionTrace :: [TracePeerSelection extraDebugState extraFlags extraPeers extraTrace peeraddr], -- | An updated state to use immediately decisionState :: PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn, @@ -1643,29 +1584,29 @@ data Decision m extraState extraDebugState extraFlags extraPeers peeraddr peerco -- a further 'Decision'. This gives a state update to apply upon -- completion, but also allows chaining further job actions. -- - decisionJobs :: [Job () m (Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn)] + decisionJobs :: [Job () m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn)] } -- | Decision which has access to the current time, rather than the time when -- the governor's loop blocked to make a decision. -- -type TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn = - Time -> Decision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn +type TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn = + Time -> Decision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn -- | Type alias for function types which are used to create governor decisions. -- Almost all decisions are following this pattern. -- -type MkGuardedDecision extraState extraDebugState extraFlags extraPeers peeraddr peerconn m +type MkGuardedDecision extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn m = PeerSelectionPolicy peeraddr m -> PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Guarded (STM m) (TimedDecision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) -newtype Completion m extraState extraDebugState extraFlags extraPeers peeraddr peerconn = +newtype Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn = Completion (PeerSelectionState extraState extraFlags extraPeers peeraddr peerconn - -> Time -> Decision m extraState extraDebugState extraFlags extraPeers peeraddr peerconn) + -> Time -> Decision m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn) -data TracePeerSelection extraDebugState extraFlags extraPeers peeraddr = +data TracePeerSelection extraDebugState extraFlags extraPeers extraTrace peeraddr = TraceLocalRootPeersChanged (LocalRootPeers extraFlags peeraddr) (LocalRootPeers extraFlags peeraddr) -- @@ -1836,10 +1777,8 @@ data TracePeerSelection extraDebugState extraFlags extraPeers peeraddr = -- timeouts the governor will still look to remove or -- add peers as required. - | TraceLedgerStateJudgementChanged LedgerStateJudgement | TraceOnlyBootstrapPeers | TraceBootstrapPeersFlagChangedWhilstInSensitiveState - | TraceUseBootstrapPeersChanged UseBootstrapPeers | TraceVerifyPeerSnapshot Bool -- @@ -1852,6 +1791,8 @@ data TracePeerSelection extraDebugState extraFlags extraPeers peeraddr = -- | TraceDebugState Time (DebugPeerSelectionState extraDebugState extraFlags extraPeers peeraddr) + + | ExtraTrace extraTrace deriving Show diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs index ca2c493171e..b78789d4d8d 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs @@ -24,11 +24,8 @@ module Ouroboros.Network.PeerSelection.State.LocalRootPeers , toGroupSets , toMap , keysSet - , trustableKeysSet -- * Special operations , clampToLimit - , clampToTrustable - , isPeerTrustable ) where import Prelude hiding (null) @@ -38,8 +35,6 @@ import Data.Map.Strict qualified as Map import Data.Set (Set) import Data.Set qualified as Set -import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) - import Ouroboros.Network.DiffusionMode import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise) @@ -241,49 +236,3 @@ clampToLimit totalLimit (LocalRootPeers m gs0) = !w' = min w (WarmValency (Set.size g')) !h' = HotValency (getHotValency h `min` getWarmValency w') = [(h', w', g')] - -clampToTrustable :: Ord peeraddr - => LocalRootPeers PeerTrustable peeraddr - -> LocalRootPeers PeerTrustable peeraddr -clampToTrustable (LocalRootPeers m gs) = - let trustedMap = Map.filter (\LocalRootConfig { extraFlags } -> case extraFlags of - IsTrustable -> True - IsNotTrustable -> False - ) - m - in LocalRootPeers trustedMap (trustedGroups gs) - where - trustedGroups [] = [] - trustedGroups ((h, w, g):gss) = - let trusted = Map.filter (\LocalRootConfig { extraFlags } -> case extraFlags of - IsTrustable -> True - IsNotTrustable -> False - ) - m - trustedSet = Map.keysSet trusted - trustedGroup = Set.intersection g trustedSet - w' = min w (WarmValency (Set.size trustedGroup)) - h' = HotValency (getHotValency h `min` getWarmValency w') - in if Set.null trustedGroup - then trustedGroups gss - else (h', w', trustedGroup) : trustedGroups gss - -isPeerTrustable :: Ord peeraddr - => peeraddr - -> LocalRootPeers PeerTrustable peeraddr - -> Bool -isPeerTrustable peeraddr lrp = - case Map.lookup peeraddr (toMap lrp) of - Just LocalRootConfig { extraFlags = IsTrustable } - -> True - _ -> False - -trustableKeysSet :: LocalRootPeers PeerTrustable peeraddr - -> Set peeraddr -trustableKeysSet (LocalRootPeers m _) = - Map.keysSet - . Map.filter (\LocalRootConfig { extraFlags } -> - case extraFlags of - IsTrustable -> True - IsNotTrustable -> False) - $ m diff --git a/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs index 500cefd78b3..076fe56e807 100644 --- a/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs +++ b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V1.hs @@ -41,8 +41,6 @@ import Control.Tracer (Tracer, traceWith) import Network.TypedProtocol.Core (N, Nat (..), natToInt) -import Cardano.Network.NodeToNode.Version (NodeToNodeVersion) - import Ouroboros.Network.Protocol.TxSubmission2.Server import Ouroboros.Network.Protocol.TxSubmission2.Type import Ouroboros.Network.TxSubmission.Inbound.V2.Types (ProcessedTxCount (..), @@ -123,7 +121,7 @@ initialServerState = ServerState 0 Seq.empty Map.empty Map.empty 0 txSubmissionInbound - :: forall txid tx idx m. + :: forall txid tx idx m version. ( Ord txid , NoThunks txid , NoThunks tx @@ -136,7 +134,7 @@ txSubmissionInbound -> NumTxIdsToAck -- ^ Maximum number of unacknowledged txids allowed -> TxSubmissionMempoolReader txid tx idx m -> TxSubmissionMempoolWriter txid tx idx m - -> NodeToNodeVersion + -> version -> TxSubmissionServerPipelined txid tx m () txSubmissionInbound tracer initDelay (NumTxIdsToAck maxUnacked) mpReader mpWriter _version = TxSubmissionServerPipelined $ do diff --git a/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs index 79784f8dfa9..4f82878bb7a 100644 --- a/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs +++ b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/Registry.hs @@ -25,6 +25,7 @@ import Control.Monad.Class.MonadFork import Control.Monad.Class.MonadThrow import Control.Monad.Class.MonadTime.SI import Control.Monad.Class.MonadTimer.SI +import Control.Tracer (Tracer, traceWith) import Data.Foldable as Foldable (foldl', traverse_) import Data.Hashable @@ -37,7 +38,6 @@ import Data.Set qualified as Set import Data.Typeable (Typeable) import Data.Void (Void) -import Control.Tracer (Tracer, traceWith) import Ouroboros.Network.Protocol.TxSubmission2.Type import Ouroboros.Network.TxSubmission.Inbound.V2.Decision import Ouroboros.Network.TxSubmission.Inbound.V2.Policy diff --git a/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs b/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs index b5cce262b3b..0a489afc210 100644 --- a/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs +++ b/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs @@ -19,7 +19,6 @@ module Ouroboros.Network.OrphanInstances , peerSelectionTargetsToObject ) where -import Cardano.Network.NodeToClient (LocalAddress (..), ProtocolLimitFailure) import Control.Applicative (Alternative ((<|>))) import Control.Exception (Exception (..)) import Control.Monad (zipWithM) @@ -99,7 +98,7 @@ import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LRP import Ouroboros.Network.Server qualified as Server import Ouroboros.Network.Server.RateLimiting (AcceptConnectionsPolicyTrace (..), AcceptedConnectionsLimit (..)) -import Ouroboros.Network.Snocket (RemoteAddress) +import Ouroboros.Network.Snocket (LocalAddress (..), RemoteAddress) import Ouroboros.Network.TxSubmission.Inbound.V2 (ProcessedTxCount (..), TraceTxLogic (..), TraceTxSubmissionInbound (..)) import Ouroboros.Network.TxSubmission.Outbound (TraceTxSubmissionOutbound (..)) @@ -847,12 +846,13 @@ instance ToJSON Time where instance ( ToJSON extraDebugState , ToJSON extraFlags , ToJSON extraPeers + , ToJSON extraTracer , ToJSON peerAddr , ToJSONKey peerAddr , Ord peerAddr , ToJSON (PublicRootPeers.PublicRootPeers extraPeers peerAddr) ) - => ToJSON (TracePeerSelection extraDebugState extraFlags extraPeers peerAddr) where + => ToJSON (TracePeerSelection extraDebugState extraFlags extraPeers extraTracer peerAddr) where toJSON (TraceLocalRootPeersChanged lrp lrp') = object [ "kind" .= String "LocalRootPeersChanged" , "previous" .= lrp @@ -1132,16 +1132,10 @@ instance ( ToJSON extraDebugState , "selected" .= selected , "available" .= available ] - toJSON (TraceLedgerStateJudgementChanged new) = - object [ "kind" .= String "LedgerStateJudgementChanged" - , "LedgerStateJudgement" .= show new - ] + toJSON (ExtraTrace extraTrace) = + toJSON extraTrace toJSON TraceOnlyBootstrapPeers = object [ "kind" .= String "OnlyBootstrapPeers" ] - toJSON (TraceUseBootstrapPeersChanged ubp) = - object [ "kind" .= String "UseBootstrapPeersChanged" - , "UseBootstrapPeers" .= show ubp - ] toJSON TraceBootstrapPeersFlagChangedWhilstInSensitiveState = object [ "kind" .= String "BootstrapPeersFlagChangedWhilstInSensitiveState" ] diff --git a/ouroboros-network/ouroboros-network.cabal b/ouroboros-network/ouroboros-network.cabal index 4c5efed6e04..fa18938acb1 100644 --- a/ouroboros-network/ouroboros-network.cabal +++ b/ouroboros-network/ouroboros-network.cabal @@ -20,12 +20,6 @@ flag asserts manual: False default: False -flag cddl - description: Enable CDDL based tests of the CBOR encoding - manual: True - -- These tests need the cddl and the cbor-diag Ruby-package - default: True - flag ipv6 description: Enable IPv6 test cases manual: True @@ -70,13 +64,6 @@ library api visibility: public hs-source-dirs: api/lib exposed-modules: - Cardano.Network.ConsensusMode - Cardano.Network.NodeToClient.Version - Cardano.Network.NodeToNode.Version - Cardano.Network.PeerSelection.Bootstrap - Cardano.Network.PeerSelection.LocalRootPeers - Cardano.Network.PeerSelection.PeerTrustable - Cardano.Network.Types Ouroboros.Network.AnchoredFragment Ouroboros.Network.AnchoredSeq Ouroboros.Network.Block @@ -127,6 +114,7 @@ library api library api-tests-lib import: ghc-options + visibility: public hs-source-dirs: api/tests-lib exposed-modules: Ouroboros.Network.Mock.Chain @@ -154,9 +142,6 @@ test-suite api-tests main-is: Main.hs hs-source-dirs: api/tests other-modules: - Test.Cardano.Network.NodeToClient.Version - Test.Cardano.Network.NodeToNode.Version - Test.Cardano.Network.Version Test.Ouroboros.Network.AnchoredFragment Test.Ouroboros.Network.Chain Test.Ouroboros.Network.PeerSelection.RelayAccessPoint @@ -171,7 +156,6 @@ test-suite api-tests iproute, ouroboros-network:{api, api-tests-lib, tests-lib}, tasty, - tasty-hunit, tasty-quickcheck, with-utf8, @@ -596,7 +580,6 @@ library orphan-instances visibility: public hs-source-dirs: orphan-instances exposed-modules: - Cardano.Network.OrphanInstances Ouroboros.Network.OrphanInstances reexported-modules: @@ -632,7 +615,7 @@ library orphan-instances iproute, network, network-mux, - ouroboros-network:{ouroboros-network, api, cardano-diffusion, framework, protocols}, + ouroboros-network:{ouroboros-network, api, framework, protocols}, text, typed-protocols, @@ -667,73 +650,6 @@ executable demo-connection-manager random, typed-protocols:{typed-protocols, examples}, -library cardano-diffusion - import: ghc-options - visibility: public - hs-source-dirs: cardano-diffusion - exposed-modules: - Cardano.Network.Diffusion - Cardano.Network.Diffusion.Configuration - Cardano.Network.Diffusion.Handlers - Cardano.Network.Diffusion.Policies - Cardano.Network.Diffusion.Topology - Cardano.Network.Diffusion.Types - Cardano.Network.LedgerPeerConsensusInterface - Cardano.Network.NodeToClient - Cardano.Network.NodeToNode - Cardano.Network.PeerSelection.Churn - Cardano.Network.PeerSelection.ExtraRootPeers - Cardano.Network.PeerSelection.Governor.Monitor - Cardano.Network.PeerSelection.Governor.PeerSelectionActions - Cardano.Network.PeerSelection.Governor.PeerSelectionState - Cardano.Network.PeerSelection.Governor.Types - Cardano.Network.PeerSelection.PeerSelectionActions - Cardano.Network.PeerSelection.PublicRootPeers - - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - other-extensions: - BangPatterns - DataKinds - EmptyCase - ExistentialQuantification - FlexibleContexts - FlexibleInstances - FunctionalDependencies - GADTSyntax - GADTs - GeneralizedNewtypeDeriving - MultiParamTypeClasses - NamedFieldPuns - OverloadedStrings - PolyKinds - RankNTypes - RecordWildCards - ScopedTypeVariables - TemplateHaskell - TupleSections - TypeApplications - TypeFamilies - TypeInType - - build-depends: - base >=4.14 && <4.22, - bytestring, - containers, - contra-tracer, - dns, - io-classes:{io-classes, si-timers, strict-stm} ^>=1.8, - monoidal-synchronisation, - network ^>=3.2.7, - network-mux, - ouroboros-network:{ouroboros-network, api, framework, protocols}, - random, - typed-protocols:{typed-protocols, stateful} ^>=1.1, - - if !os(windows) - build-depends: - unix - library protocols import: ghc-options visibility: public @@ -851,7 +767,6 @@ library protocols-tests-lib Ouroboros.Network.Protocol.LocalTxSubmission.Direct Ouroboros.Network.Protocol.LocalTxSubmission.Examples Ouroboros.Network.Protocol.LocalTxSubmission.Test - Ouroboros.Network.Protocol.PeerSharing.Codec.CDDL Ouroboros.Network.Protocol.PeerSharing.Direct Ouroboros.Network.Protocol.PeerSharing.Examples Ouroboros.Network.Protocol.PeerSharing.Test @@ -875,7 +790,6 @@ library protocols-tests-lib deepseq, io-classes:{io-classes, si-timers, strict-stm}, io-sim, - network, network-mux, ouroboros-network:{api, api-tests-lib, framework, protocols, tests-lib}, pipes, @@ -902,71 +816,6 @@ test-suite protocols-tests -Wunused-packages -rtsopts -test-suite protocols-cddl - import: ghc-options - type: exitcode-stdio-1.0 - hs-source-dirs: protocols/cddl - main-is: Main.hs - - if flag(cddl) - buildable: True - else - buildable: False - - build-depends: - QuickCheck, - base >=4.14 && <4.22, - bytestring, - cborg, - containers, - directory, - filepath, - mtl, - network, - ouroboros-network:{api, api-tests-lib, framework, protocols, protocols-tests-lib}, - process-extras, - quickcheck-instances, - serialise, - tasty, - tasty-hunit, - tasty-quickcheck, - temporary, - text, - typed-protocols:{typed-protocols, stateful}, - - ghc-options: - -threaded - -Wall - -rtsopts - -with-rtsopts=-M400m - -test-suite protocols-bench - import: ghc-options-tests - type: exitcode-stdio-1.0 - default-extensions: ImportQualifiedPost - hs-source-dirs: protocols/bench - main-is: Main.hs - build-depends: - base >=4.14 && <4.22, - bytestring, - cborg, - containers, - deepseq, - network, - ouroboros-network:{api, framework, protocols, protocols-tests-lib}, - tasty-bench, - typed-protocols:{typed-protocols, stateful}, - - ghc-options: - -rtsopts - -with-rtsopts=-A32m - -with-rtsopts=-T - - -- Important for comparing benchmarks results against a baseline run. - -- Read: https://hackage.haskell.org/package/tasty-bench for details - if impl(ghc >=8.6) - ghc-options: -fproc-alignment=64 - -- Simulation Test Library library ouroboros-network-tests-lib import: ghc-options-tests @@ -994,10 +843,8 @@ library ouroboros-network-tests-lib network, network-mux, nothunks, - ouroboros-network:{ouroboros-network, api, api-tests-lib, cardano-diffusion, framework, framework-tests-lib, orphan-instances, protocols, protocols-tests-lib, tests-lib}, - pipes, + ouroboros-network:{ouroboros-network, api, api-tests-lib, framework, framework-tests-lib, protocols, protocols-tests-lib, tests-lib}, pretty-simple, - psqueues, random, serialise, splitmix, @@ -1006,38 +853,26 @@ library ouroboros-network-tests-lib tasty-quickcheck, text, time >=1.9.1 && <1.14, - typed-protocols:{typed-protocols, examples}, + typed-protocols, exposed-modules: Ouroboros.Network.BlockFetch.Examples Ouroboros.Network.MockNode - Test.Cardano.Network.OrphanInstances.Tests Test.Ouroboros.Network.BlockFetch Test.Ouroboros.Network.Diffusion.Node Test.Ouroboros.Network.Diffusion.Node.ChainDB Test.Ouroboros.Network.Diffusion.Node.Kernel - Test.Ouroboros.Network.Diffusion.Node.MiniProtocols - Test.Ouroboros.Network.Diffusion.Policies - Test.Ouroboros.Network.Diffusion.Testnet.Cardano - Test.Ouroboros.Network.Diffusion.Testnet.Cardano.Simulation Test.Ouroboros.Network.KeepAlive Test.Ouroboros.Network.LedgerPeers Test.Ouroboros.Network.MockNode Test.Ouroboros.Network.Mux Test.Ouroboros.Network.Orphans - Test.Ouroboros.Network.PeerSelection - Test.Ouroboros.Network.PeerSelection.Cardano.Instances - Test.Ouroboros.Network.PeerSelection.Cardano.LocalRootPeers - Test.Ouroboros.Network.PeerSelection.Cardano.MockEnvironment - Test.Ouroboros.Network.PeerSelection.Cardano.PublicRootPeers - Test.Ouroboros.Network.PeerSelection.Gource Test.Ouroboros.Network.PeerSelection.Instances Test.Ouroboros.Network.PeerSelection.KnownPeers Test.Ouroboros.Network.PeerSelection.LocalRootPeers Test.Ouroboros.Network.PeerSelection.PeerGraph Test.Ouroboros.Network.PeerSelection.PeerMetric Test.Ouroboros.Network.PeerSelection.RootPeersDNS - Test.Ouroboros.Network.PeerSelection.Utils Test.Ouroboros.Network.TxSubmission Test.Ouroboros.Network.TxSubmission.AppV1 Test.Ouroboros.Network.TxSubmission.AppV2 @@ -1083,15 +918,18 @@ test-suite ouroboros-network-io-tests QuickCheck >=2.16, base >=4.14 && <4.22, bytestring, + cborg, contra-tracer, io-classes:{io-classes, si-timers, strict-stm}, monoidal-synchronisation, network, network-mux, - ouroboros-network:{api, api-tests-lib, cardano-diffusion, framework, protocols, protocols-tests-lib, tests-lib}, + ouroboros-network:{api, api-tests-lib, framework, protocols, protocols-tests-lib, tests-lib}, serialise, tasty, tasty-quickcheck, + text, + typed-protocols, with-utf8, if os(windows) @@ -1108,30 +946,6 @@ test-suite ouroboros-network-io-tests -T -RTS -executable demo-chain-sync - import: ghc-options - hs-source-dirs: demo - main-is: chain-sync.hs - build-depends: - async, - base >=4.14 && <4.22, - bytestring, - containers, - contra-tracer, - directory, - infinite-list, - io-classes:{si-timers, strict-stm}, - network-mux, - optparse-applicative, - ouroboros-network:{ouroboros-network, api, api-tests-lib, cardano-diffusion, framework, protocols}, - random, - serialise, - typed-protocols, - - ghc-options: - -threaded - -rtsopts - benchmark sim-benchmarks import: ghc-options-tests type: exitcode-stdio-1.0 diff --git a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs index 3d68270c861..ea4bfa37dbe 100644 --- a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs +++ b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Codec.hs @@ -8,7 +8,8 @@ {-# LANGUAGE TypeOperators #-} module Ouroboros.Network.Protocol.LocalStateQuery.Codec - ( codecLocalStateQuery + ( LocalStateQueryVersion (..) + , codecLocalStateQuery , codecLocalStateQueryId , Some (..) ) where @@ -29,7 +30,6 @@ import Network.TypedProtocol.Core import Network.TypedProtocol.Stateful.Codec qualified as Stateful import Network.TypedProtocol.Stateful.Codec.CBOR qualified as Stateful -import Cardano.Network.NodeToClient.Version qualified as V import Ouroboros.Network.Protocol.LocalStateQuery.Type @@ -41,7 +41,7 @@ codecLocalStateQuery ( MonadST m , ShowQuery query ) - => V.NodeToClientVersion + => LocalStateQueryVersion -- ^ eg whether to allow 'ImmutableTip' in @'MsgAcquire' -> (point -> CBOR.Encoding) -> (forall s . CBOR.Decoder s point) @@ -56,7 +56,7 @@ codecLocalStateQuery version encodeResult decodeResult = Stateful.mkCodecCborLazyBS encode decode where - canAcquireImmutable = version >= V.NodeToClientV_16 + canAcquireImmutable = version >= LocalStateQuery_V2 encodeFailure :: AcquireFailure -> CBOR.Encoding encodeFailure AcquireFailurePointTooOld = CBOR.encodeWord8 0 diff --git a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs index 2f257c1bc5e..d37bcc2a41d 100644 --- a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs +++ b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs @@ -276,3 +276,7 @@ instance Show (State st) where show StateAcquired = "StateAcquired" show (StateQuerying _) = "StateQuerying *" show StateDone = "StateDone" + +data LocalStateQueryVersion = LocalStateQuery_V1 -- < NodeToClientV_16 + | LocalStateQuery_V2 -- >= NodeToClientV_17 + deriving (Eq, Ord, Enum, Bounded, Show) diff --git a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs index b0adcbe746f..dad4e6783db 100644 --- a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs +++ b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec.hs @@ -10,7 +10,8 @@ {-# LANGUAGE TypeOperators #-} module Ouroboros.Network.Protocol.LocalTxMonitor.Codec - ( codecLocalTxMonitor + ( LocalTxMonitorVersion (..) + , codecLocalTxMonitor , codecLocalTxMonitorId ) where @@ -29,7 +30,6 @@ import Codec.CBOR.Encoding qualified as CBOR import Codec.CBOR.Read qualified as CBOR import Text.Printf -import Cardano.Network.NodeToClient.Version qualified as V import Ouroboros.Network.Protocol.LocalTxMonitor.Type codecLocalTxMonitor :: @@ -37,7 +37,7 @@ codecLocalTxMonitor :: ( MonadST m , ptcl ~ LocalTxMonitor txid tx slot ) - => V.NodeToClientVersion + => LocalTxMonitorVersion -- ^ Whether to accept `MsgGetMeasures` -> (txid -> CBOR.Encoding) -> (forall s. CBOR.Decoder s txid) @@ -52,7 +52,7 @@ codecLocalTxMonitor version encodeSlot decodeSlot = mkCodecCborLazyBS encode decode where - canHandleMeasures = version >= V.NodeToClientV_20 + canHandleMeasures = version >= LocalTxMonitor_V2 encode :: forall (st :: ptcl) (st' :: ptcl). diff --git a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs index c36cb698273..4e8bfe04f5a 100644 --- a/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs +++ b/ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs @@ -311,3 +311,8 @@ instance ( NFData txid deriving instance (Show txid, Show tx, Show slot) => Show (Message (LocalTxMonitor txid tx slot) from to) + + +data LocalTxMonitorVersion = LocalTxMonitor_V1 -- < NodeToClientV_20 + | LocalTxMonitor_V2 -- >= NodeToClientV_20 + deriving (Eq, Ord, Enum, Bounded, Show) diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs index 96ff035344e..96afd91836d 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/Handshake/Test.hs @@ -48,15 +48,10 @@ import Network.TypedProtocol.Proofs import Test.Ouroboros.Network.Protocol.Utils (prop_codec_cborM, prop_codec_valid_cbor_encoding, splits2, splits3) -import Cardano.Network.NodeToClient.Version as NTC -import Cardano.Network.NodeToNode.Version as NTN - import Ouroboros.Network.Channel import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Driver.Simple (runConnectedPeers, runConnectedPeersAsymmetric, runPeer) -import Ouroboros.Network.Magic -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Ouroboros.Network.Snocket (TestAddress (..)) import Ouroboros.Network.Snocket qualified as Snocket import Simulation.Network.Snocket @@ -99,46 +94,6 @@ tests = prop_channel_simultaneous_open_SimNet ] - , testGroup "NodeToNode" - [ testProperty "acceptable_symmetric" - prop_acceptable_symmetric_NodeToNode - , testProperty "acceptOrRefuse" - prop_acceptOrRefuse_symmetric_NodeToNode - , testProperty "simultaneous open ST" - prop_channel_simultaneous_open_NodeToNode_ST - , testProperty "simultaneous open IO" - prop_channel_simultaneous_open_NodeToNode_IO - , testProperty "simultaneous open SimNet" - prop_channel_simultaneous_open_NodeToNode_SimNet - , testProperty "query version ST" - prop_query_version_NodeToNode_ST - , testProperty "query version IO" - prop_query_version_NodeToNode_IO - , testProperty "query version SimNet" - prop_query_version_NodeToNode_SimNet - , testProperty "peerSharing symmetry" - prop_peerSharing_symmetric_NodeToNode_SimNet - ] - - , testGroup "NodeToClient" - [ testProperty "acceptable_symmetric" - prop_acceptable_symmetric_NodeToClient - , testProperty "acceptOrRefuse" - prop_acceptOrRefuse_symmetric_NodeToClient - , testProperty "simultaneous open ST" - prop_channel_simultaneous_open_NodeToClient_ST - , testProperty "simultaneous open IO" - prop_channel_simultaneous_open_NodeToClient_IO - , testProperty "simultaneous open SimNet" - prop_channel_simultaneous_open_NodeToClient_SimNet - , testProperty "query version ST" - prop_query_version_NodeToClient_ST - , testProperty "query version IO" - prop_query_version_NodeToClient_IO - , testProperty "query version SimNet" - prop_query_version_NodeToClient_SimNet - ] - , testProperty "codec RefuseReason" prop_codec_RefuseReason , testProperty "codec" prop_codec_Handshake , testProperty "codec 2-splits" prop_codec_splits2_Handshake @@ -631,151 +586,6 @@ prop_pipe_asymmetric_IO (ArbitraryVersions clientVersions _serverVersions) = --- --- NodeToNode generators --- - -newtype ArbitraryNodeToNodeVersion = - ArbitraryNodeToNodeVersion { getNodeToNodeVersion :: NodeToNodeVersion } - deriving Show - -instance Arbitrary ArbitraryNodeToNodeVersion where - arbitrary = elements (ArbitraryNodeToNodeVersion <$> [minBound .. maxBound]) - -newtype ArbitraryNodeToNodeVersionData = - ArbitraryNodeToNodeVersionData - { getNodeToNodeVersionData :: NodeToNodeVersionData } - deriving Show - deriving Acceptable via NodeToNodeVersionData - --- | With the introduction of PeerSharing to 'NodeToNodeVersionData' this type's --- 'Acceptable' instance is no longer symmetric. Because when handshake is --- performed we keep only the remote's side PeerSharing information. Due to this, --- the 'ArbitraryNodeToNodeVersionData' needs to have a custom 'Eq' type that --- ignores this parameter. We also ignore the query field which may differ --- between parties. --- -instance Eq ArbitraryNodeToNodeVersionData where - (==) (ArbitraryNodeToNodeVersionData (NodeToNodeVersionData nm dm ps _)) - (ArbitraryNodeToNodeVersionData (NodeToNodeVersionData nm' dm' ps' _)) - = nm == nm' && dm == dm' && ps == ps' - -instance Queryable ArbitraryNodeToNodeVersionData where - queryVersion = queryVersion . getNodeToNodeVersionData - -instance Arbitrary ArbitraryNodeToNodeVersionData where - arbitrary = fmap (fmap (fmap ArbitraryNodeToNodeVersionData)) - . NodeToNodeVersionData - <$> (NetworkMagic <$> arbitrary) - <*> elements [ InitiatorOnlyDiffusionMode - , InitiatorAndResponderDiffusionMode - ] - <*> elements [ PeerSharingDisabled - , PeerSharingEnabled - ] - <*> arbitrary - shrink (ArbitraryNodeToNodeVersionData - (NodeToNodeVersionData magic mode peerSharing query)) = - [ ArbitraryNodeToNodeVersionData (NodeToNodeVersionData magic' mode peerSharing' query) - | magic' <- NetworkMagic <$> shrink (unNetworkMagic magic) - , peerSharing' <- shrinkPeerSharing peerSharing - ] - ++ - [ ArbitraryNodeToNodeVersionData (NodeToNodeVersionData magic mode' peerSharing' query) - | mode' <- shrinkMode mode - , peerSharing' <- shrinkPeerSharing peerSharing - ] - ++ - [ ArbitraryNodeToNodeVersionData (NodeToNodeVersionData magic mode peerSharing' query') - | query' <- shrink query - , peerSharing' <- shrinkPeerSharing peerSharing - ] - where - shrinkMode :: DiffusionMode -> [DiffusionMode] - shrinkMode InitiatorOnlyDiffusionMode = [] - shrinkMode InitiatorAndResponderDiffusionMode = [InitiatorOnlyDiffusionMode] - - shrinkPeerSharing PeerSharingDisabled = [] - shrinkPeerSharing PeerSharingEnabled = [PeerSharingDisabled] - -newtype ArbitraryNodeToNodeVersions = - ArbitraryNodeToNodeVersions - { getArbitraryNodeToNodeVersiosn :: Versions NodeToNodeVersion - ArbitraryNodeToNodeVersionData Bool } - -instance Show ArbitraryNodeToNodeVersions where - show (ArbitraryNodeToNodeVersions (Versions vs)) - = "ArbitraryNodeToNodeVersions " ++ show (Map.map versionData vs) - -instance Arbitrary ArbitraryNodeToNodeVersions where - arbitrary = do - vs <- listOf (getNodeToNodeVersion <$> arbitrary) - ds <- vectorOf (length vs) arbitrary - r <- arbitrary - return $ ArbitraryNodeToNodeVersions - $ Versions - $ Map.fromList - [ (v, Version (const r) d) - | (v, d) <- zip vs ds - ] - -- TODO: shrink (issue #3407) - - --- --- NodeToClient generators --- - -newtype ArbitraryNodeToClientVersion = - ArbitraryNodeToClientVersion { getNodeToClientVersion :: NodeToClientVersion } - deriving Show - -instance Arbitrary ArbitraryNodeToClientVersion where - arbitrary = elements (ArbitraryNodeToClientVersion <$> [minBound .. maxBound]) - -newtype ArbitraryNodeToClientVersionData = - ArbitraryNodeToClientVersionData - { getNodeToClientVersionData :: NodeToClientVersionData } - deriving Show - -instance Arbitrary ArbitraryNodeToClientVersionData where - arbitrary = ( (ArbitraryNodeToClientVersionData .) - . NodeToClientVersionData - ) - <$> (NetworkMagic <$> arbitrary) - <*> arbitrary - shrink (ArbitraryNodeToClientVersionData - (NodeToClientVersionData magic query)) = - [ ArbitraryNodeToClientVersionData (NodeToClientVersionData magic' query) - | magic' <- NetworkMagic <$> shrink (unNetworkMagic magic) - ] - ++ - [ ArbitraryNodeToClientVersionData (NodeToClientVersionData magic query') - | query' <- shrink query - ] - -newtype ArbitraryNodeToClientVersions = - ArbitraryNodeToClientVersions - { getArbitraryNodeToClientVersiosn :: Versions NodeToClientVersion - NodeToClientVersionData Bool } - -instance Show ArbitraryNodeToClientVersions where - show (ArbitraryNodeToClientVersions (Versions vs)) - = "ArbitraryNodeToClientVersions " ++ show (Map.map versionData vs) - -instance Arbitrary ArbitraryNodeToClientVersions where - arbitrary = do - vs <- listOf (getNodeToClientVersion <$> arbitrary) - ds <- vectorOf (length vs) (getNodeToClientVersionData <$> arbitrary) - r <- arbitrary - return $ ArbitraryNodeToClientVersions - $ Versions - $ Map.fromList - [ (v, Version (const r) d) - | (v, d) <- zip vs ds - ] - -- TODO: shrink (issue #3407) - - prop_acceptable_symmetric :: ( Acceptable vData , Eq vData @@ -797,132 +607,6 @@ prop_acceptable_symmetric_VersionData a b = prop_acceptable_symmetric a b -prop_acceptable_symmetric_NodeToNode - :: ArbitraryNodeToNodeVersionData - -> ArbitraryNodeToNodeVersionData - -> Bool -prop_acceptable_symmetric_NodeToNode a b = - prop_acceptable_symmetric a b - - -prop_acceptable_symmetric_NodeToClient - :: ArbitraryNodeToClientVersionData - -> ArbitraryNodeToClientVersionData - -> Bool -prop_acceptable_symmetric_NodeToClient (ArbitraryNodeToClientVersionData a) - (ArbitraryNodeToClientVersionData b) = - prop_acceptable_symmetric a b - - --- | Run 'prop_query_version' in the simulation monad. --- -prop_query_version_NodeToNode_ST :: ArbitraryNodeToNodeVersions - -> ArbitraryNodeToNodeVersions - -> Property -prop_query_version_NodeToNode_ST - (ArbitraryNodeToNodeVersions clientVersions) - (ArbitraryNodeToNodeVersions serverVersions) = - runSimOrThrow $ prop_query_version - createConnectedChannels - (codecHandshake nodeToNodeVersionCodec) - (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) - clientVersions - serverVersions - (\(ArbitraryNodeToNodeVersionData vd) -> - ArbitraryNodeToNodeVersionData $ - vd { NTN.query = True - , NTN.peerSharing = PeerSharingEnabled - }) - --- | Run 'prop_query_version' in the IO monad. --- -prop_query_version_NodeToNode_IO :: ArbitraryNodeToNodeVersions - -> ArbitraryNodeToNodeVersions - -> Property -prop_query_version_NodeToNode_IO - (ArbitraryNodeToNodeVersions clientVersions) - (ArbitraryNodeToNodeVersions serverVersions) = - ioProperty $ prop_query_version - createConnectedChannels - (codecHandshake nodeToNodeVersionCodec) - (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) - clientVersions - serverVersions - (\(ArbitraryNodeToNodeVersionData vd) -> - ArbitraryNodeToNodeVersionData $ - vd { NTN.query = True - , NTN.peerSharing = PeerSharingEnabled - }) - --- | Run 'prop_query_version' with SimNet. --- -prop_query_version_NodeToNode_SimNet :: ArbitraryNodeToNodeVersions - -> ArbitraryNodeToNodeVersions - -> Property -prop_query_version_NodeToNode_SimNet - (ArbitraryNodeToNodeVersions clientVersions) - (ArbitraryNodeToNodeVersions serverVersions) = - runSimOrThrow $ prop_query_version - createConnectedChannels - (codecHandshake nodeToNodeVersionCodec) - (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) - clientVersions - serverVersions - (\(ArbitraryNodeToNodeVersionData vd) -> - ArbitraryNodeToNodeVersionData $ - vd { NTN.query = True - , NTN.peerSharing = PeerSharingEnabled - }) - --- | Run 'prop_query_version' in the simulation monad. --- -prop_query_version_NodeToClient_ST :: ArbitraryNodeToClientVersions - -> ArbitraryNodeToClientVersions - -> Property -prop_query_version_NodeToClient_ST - (ArbitraryNodeToClientVersions clientVersions) - (ArbitraryNodeToClientVersions serverVersions) = - runSimOrThrow $ prop_query_version - createConnectedChannels - (codecHandshake nodeToClientVersionCodec) - (cborTermVersionDataCodec nodeToClientCodecCBORTerm) - clientVersions - serverVersions - (\vd -> vd {NTC.query = True}) - --- | Run 'prop_query_version' in the IO monad. --- -prop_query_version_NodeToClient_IO :: ArbitraryNodeToClientVersions - -> ArbitraryNodeToClientVersions - -> Property -prop_query_version_NodeToClient_IO - (ArbitraryNodeToClientVersions clientVersions) - (ArbitraryNodeToClientVersions serverVersions) = - ioProperty $ prop_query_version - createConnectedChannels - (codecHandshake nodeToClientVersionCodec) - (cborTermVersionDataCodec nodeToClientCodecCBORTerm) - clientVersions - serverVersions - (\vd -> vd {NTC.query = True}) - --- | Run 'prop_query_version' with SimNet. --- -prop_query_version_NodeToClient_SimNet :: ArbitraryNodeToClientVersions - -> ArbitraryNodeToClientVersions - -> Property -prop_query_version_NodeToClient_SimNet - (ArbitraryNodeToClientVersions clientVersions) - (ArbitraryNodeToClientVersions serverVersions) = - runSimOrThrow $ prop_query_version - createConnectedChannels - (codecHandshake nodeToClientVersionCodec) - (cborTermVersionDataCodec nodeToClientCodecCBORTerm) - clientVersions - serverVersions - (\vd -> vd {NTC.query = True}) - - -- | Run a query for the server's supported version. -- prop_query_version :: ( MonadAsync m @@ -972,65 +656,8 @@ prop_query_version createChannels codec versionDataCodec clientVersions serverVe clientVersions' = setQueryVersions clientVersions --- | Run a query for the server's supported version. --- -prop_peerSharing_symmetric :: - ( MonadAsync m - , MonadCatch m - ) - => m (Channel m ByteString, Channel m ByteString) - -> Codec (Handshake NodeToNodeVersion CBOR.Term) - CBOR.DeserialiseFailure m ByteString - -> VersionDataCodec CBOR.Term NodeToNodeVersion ArbitraryNodeToNodeVersionData - -> Versions NodeToNodeVersion ArbitraryNodeToNodeVersionData Bool - -> Versions NodeToNodeVersion ArbitraryNodeToNodeVersionData Bool - -> m Property -prop_peerSharing_symmetric createChannels codec versionDataCodec clientVersions serverVersions = do - (clientRes, serverRes) <- - runConnectedPeers - createChannels nullTracer codec - (handshakeClientPeer - versionDataCodec - acceptableVersion - clientVersions) - (handshakeServerPeer - versionDataCodec - acceptableVersion - queryVersion - serverVersions) - pure $ case (clientRes, serverRes) of - -- TODO: make this return ArbitraryNodeToNodeVersionData rather than a pair - -- of NodeToNodeVersionData - ( Right (HandshakeNegotiationResult _ v (ArbitraryNodeToNodeVersionData clientResult)) - , Right (HandshakeNegotiationResult _ v' (ArbitraryNodeToNodeVersionData serverResult)) - ) | v == v' - , v >= NodeToNodeV_14 -> - counterexample - ("VersionNumber: " ++ show v) - $ clientResult === serverResult - | v == v' - , v < NodeToNodeV_14 -> property True - | otherwise -> counterexample "Version mismatch" False - (Right _, Left _) -> counterexample "Acceptance mismatch" False - (Left _, Right _) -> counterexample "Acceptance mismatch" False - _ -> property True - -- | Run 'prop_peerSharing_symmetric' with SimNet. -- -prop_peerSharing_symmetric_NodeToNode_SimNet - :: ArbitraryNodeToNodeVersions - -> ArbitraryNodeToNodeVersions - -> Property -prop_peerSharing_symmetric_NodeToNode_SimNet - (ArbitraryNodeToNodeVersions clientVersions) - (ArbitraryNodeToNodeVersions serverVersions) = - runSimOrThrow $ prop_peerSharing_symmetric - createConnectedChannels - (codecHandshake nodeToNodeVersionCodec) - (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) - clientVersions - serverVersions - -- | 'acceptOrRefuse' is symmetric in the following sense: -- -- Either both sides: @@ -1092,26 +719,6 @@ prop_acceptOrRefuse_symmetric_VersionData (ArbitraryVersions a b) = prop_acceptOrRefuse_symmetric a b -prop_acceptOrRefuse_symmetric_NodeToNode - :: ArbitraryNodeToNodeVersions - -> ArbitraryNodeToNodeVersions - -> Property -prop_acceptOrRefuse_symmetric_NodeToNode (ArbitraryNodeToNodeVersions a) - (ArbitraryNodeToNodeVersions b) = - - prop_acceptOrRefuse_symmetric a b - - -prop_acceptOrRefuse_symmetric_NodeToClient - :: ArbitraryNodeToClientVersions - -> ArbitraryNodeToClientVersions - -> Property -prop_acceptOrRefuse_symmetric_NodeToClient (ArbitraryNodeToClientVersions a) - (ArbitraryNodeToClientVersions b) = - - prop_acceptOrRefuse_symmetric a b - - -- | Run two handshake clients against each other, which simulates a TCP -- simultaneous open. -- @@ -1195,69 +802,6 @@ prop_channel_simultaneous_open_IO (ArbitraryVersions clientVersions serverVersio serverVersions -prop_channel_simultaneous_open_NodeToNode_ST :: ArbitraryNodeToNodeVersions - -> ArbitraryNodeToNodeVersions - -> Property -prop_channel_simultaneous_open_NodeToNode_ST - (ArbitraryNodeToNodeVersions clientVersions) - (ArbitraryNodeToNodeVersions serverVersions) = - runSimOrThrow $ prop_channel_simultaneous_open - createConnectedChannels - (codecHandshake nodeToNodeVersionCodec) - (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) - clientVersions - serverVersions - -transformNodeToNodeVersionData :: CodecCBORTerm Text NodeToNodeVersionData - -> CodecCBORTerm Text ArbitraryNodeToNodeVersionData -transformNodeToNodeVersionData (CodecCBORTerm g h) = - CodecCBORTerm { encodeTerm = \(ArbitraryNodeToNodeVersionData a) -> g a - , decodeTerm = fmap (fmap ArbitraryNodeToNodeVersionData) h - } - - -prop_channel_simultaneous_open_NodeToNode_IO :: ArbitraryNodeToNodeVersions - -> ArbitraryNodeToNodeVersions - -> Property -prop_channel_simultaneous_open_NodeToNode_IO - (ArbitraryNodeToNodeVersions clientVersions) - (ArbitraryNodeToNodeVersions serverVersions) = - ioProperty $ prop_channel_simultaneous_open - createConnectedChannels - (codecHandshake nodeToNodeVersionCodec) - (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) - clientVersions - serverVersions - - -prop_channel_simultaneous_open_NodeToClient_ST :: ArbitraryNodeToClientVersions - -> ArbitraryNodeToClientVersions - -> Property -prop_channel_simultaneous_open_NodeToClient_ST - (ArbitraryNodeToClientVersions clientVersions) - (ArbitraryNodeToClientVersions serverVersions) = - runSimOrThrow $ prop_channel_simultaneous_open - createConnectedChannels - (codecHandshake nodeToClientVersionCodec) - (cborTermVersionDataCodec nodeToClientCodecCBORTerm) - clientVersions - serverVersions - - -prop_channel_simultaneous_open_NodeToClient_IO :: ArbitraryNodeToClientVersions - -> ArbitraryNodeToClientVersions - -> Property -prop_channel_simultaneous_open_NodeToClient_IO - (ArbitraryNodeToClientVersions clientVersions) - (ArbitraryNodeToClientVersions serverVersions) = - ioProperty $ prop_channel_simultaneous_open - createConnectedChannels - (codecHandshake nodeToClientVersionCodec) - (cborTermVersionDataCodec nodeToClientCodecCBORTerm) - clientVersions - serverVersions - - prop_channel_simultaneous_open_sim :: forall vNumber vData m. ( Alternative (STM m) @@ -1341,31 +885,6 @@ prop_channel_simultaneous_open_SimNet clientVersions serverVersions -prop_channel_simultaneous_open_NodeToNode_SimNet :: ArbitraryNodeToNodeVersions - -> ArbitraryNodeToNodeVersions - -> Property -prop_channel_simultaneous_open_NodeToNode_SimNet - (ArbitraryNodeToNodeVersions clientVersions) - (ArbitraryNodeToNodeVersions serverVersions) = - runSimOrThrow $ prop_channel_simultaneous_open_sim - (codecHandshake nodeToNodeVersionCodec) - (cborTermVersionDataCodec (fmap transformNodeToNodeVersionData nodeToNodeCodecCBORTerm)) - clientVersions - serverVersions - -prop_channel_simultaneous_open_NodeToClient_SimNet :: ArbitraryNodeToClientVersions - -> ArbitraryNodeToClientVersions - -> Property -prop_channel_simultaneous_open_NodeToClient_SimNet - (ArbitraryNodeToClientVersions clientVersions) - (ArbitraryNodeToClientVersions serverVersions) = - runSimOrThrow $ prop_channel_simultaneous_open_sim - (codecHandshake nodeToClientVersionCodec) - (cborTermVersionDataCodec nodeToClientCodecCBORTerm) - clientVersions - serverVersions - - -- -- Codec tests diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs index 94eff2e652a..6bb7bba12a0 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalStateQuery/Test.hs @@ -41,8 +41,8 @@ import Ouroboros.Network.Channel import Ouroboros.Network.Driver.Stateful qualified as Stateful import Ouroboros.Network.Util.ShowProxy -import Ouroboros.Network.Mock.ChainGenerators () import Ouroboros.Network.Mock.Chain (Point) +import Ouroboros.Network.Mock.ChainGenerators () import Ouroboros.Network.Mock.ConcreteBlock (Block) import Ouroboros.Network.Protocol.LocalStateQuery.Client diff --git a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs index 2293b46fac9..8e374557f70 100644 --- a/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs +++ b/ouroboros-network/protocols/tests-lib/Ouroboros/Network/Protocol/LocalTxMonitor/Codec/CDDL.hs @@ -10,7 +10,7 @@ import Ouroboros.Network.Protocol.LocalTxMonitor.Type import Ouroboros.Network.Protocol.TxSubmission2.Test (Tx, TxId) localTxMonitorCodec :: Codec (LocalTxMonitor TxId Tx SlotNo) - CBOR.DeserialiseFailure IO BL.ByteString + CBOR.DeserialiseFailure IO BL.ByteString localTxMonitorCodec = codecLocalTxMonitor maxBound diff --git a/ouroboros-network/protocols/tests/Main.hs b/ouroboros-network/protocols/tests/Main.hs index 3e1a90d9a95..4ec6b8af9ab 100644 --- a/ouroboros-network/protocols/tests/Main.hs +++ b/ouroboros-network/protocols/tests/Main.hs @@ -24,13 +24,13 @@ tests = [ Test.Data.CDDL.tests -- protocols - , Ouroboros.Network.Protocol.ChainSync.Test.tests , Ouroboros.Network.Protocol.BlockFetch.Test.tests + , Ouroboros.Network.Protocol.ChainSync.Test.tests + , Ouroboros.Network.Protocol.Handshake.Test.tests + , Ouroboros.Network.Protocol.KeepAlive.Test.tests , Ouroboros.Network.Protocol.LocalStateQuery.Test.tests , Ouroboros.Network.Protocol.LocalTxMonitor.Test.tests , Ouroboros.Network.Protocol.LocalTxSubmission.Test.tests - , Ouroboros.Network.Protocol.TxSubmission2.Test.tests - , Ouroboros.Network.Protocol.Handshake.Test.tests - , Ouroboros.Network.Protocol.KeepAlive.Test.tests , Ouroboros.Network.Protocol.PeerSharing.Test.tests + , Ouroboros.Network.Protocol.TxSubmission2.Test.tests ] diff --git a/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs b/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs index 5655dca151a..122bccb4883 100644 --- a/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs +++ b/ouroboros-network/tests/io/Test/Ouroboros/Network/Socket.hs @@ -28,10 +28,10 @@ import Control.Tracer import Network.Mux qualified as Mx import Ouroboros.Network.Mux -import Ouroboros.Network.Snocket +import Ouroboros.Network.Snocket hiding (Accept (..)) import Ouroboros.Network.Socket -import Cardano.Network.NodeToNode +-- import Cardano.Network.NodeToNode import Ouroboros.Network.Block (Tip, decodeTip, encodeTip) import Ouroboros.Network.IOManager @@ -40,7 +40,6 @@ import Ouroboros.Network.Mock.Chain (Chain, ChainUpdate, Point) import Ouroboros.Network.Mock.Chain qualified as Chain import Ouroboros.Network.Mock.ChainGenerators (TestBlockChainAndUpdates (..)) import Ouroboros.Network.Mock.ProducerState qualified as CPS -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Ouroboros.Network.Protocol.ChainSync.Client qualified as ChainSync import Ouroboros.Network.Protocol.ChainSync.Codec qualified as ChainSync import Ouroboros.Network.Protocol.ChainSync.Examples qualified as ChainSync @@ -48,8 +47,7 @@ import Ouroboros.Network.Protocol.ChainSync.Server qualified as ChainSync import Ouroboros.Network.Protocol.Handshake (HandshakeArguments (..)) import Ouroboros.Network.Protocol.Handshake.Codec (cborTermVersionDataCodec, noTimeLimitsHandshake) -import Ouroboros.Network.Protocol.Handshake.Version (acceptableVersion, - queryVersion) +import Ouroboros.Network.Protocol.Handshake.Version (simpleSingletonVersions) import Ouroboros.Network.Server.Simple qualified as Server.Simple import Ouroboros.Network.Util.ShowProxy @@ -61,6 +59,86 @@ import Test.Tasty.QuickCheck (testProperty) import Text.Printf import Text.Show.Functions () +import Codec.CBOR.Read qualified as CBOR +import Codec.CBOR.Term qualified as CBOR +import Control.Monad.Class.MonadST +import Data.Text (Text) +import Data.Text qualified as T +import Network.TypedProtocol.Codec (Codec) +import Ouroboros.Network.CodecCBORTerm +import Ouroboros.Network.Handshake.Acceptable +import Ouroboros.Network.Handshake.Queryable +import Ouroboros.Network.Protocol.Handshake.Codec qualified as Handshake +import Ouroboros.Network.Protocol.Handshake.Type (Handshake) + +-- +-- Simple testing versioning scheme +-- + +data TestVersion = TestVersion + deriving (Eq, Ord, Enum, Bounded, Show) + +newtype TestVersionData = TestVersionData { networkMagic :: NetworkMagic } + deriving (Show, Eq) + +instance Acceptable TestVersionData where + -- | Check that both side use the same 'networkMagic'. Choose smaller one + -- from both 'diffusionMode's, e.g. if one is running in 'InitiatorOnlyMode' + -- agree on it. Agree on the same 'PeerSharing' value. + acceptableVersion local remote + | networkMagic local == networkMagic remote + = Accept remote + | otherwise + = Refuse $ T.pack $ "version data mismatch: " + ++ show local + ++ " /= " ++ show remote + +instance Queryable TestVersionData where + queryVersion = const False + + +handshakeCodec :: MonadST m + => Codec (Handshake TestVersion CBOR.Term) + CBOR.DeserialiseFailure m BL.ByteString +handshakeCodec = Handshake.codecHandshake CodecCBORTerm { encodeTerm, decodeTerm } + where + encodeTerm :: TestVersion -> CBOR.Term + encodeTerm TestVersion = CBOR.TInt 1 + + decodeTerm :: CBOR.Term -> Either (Text, Maybe Int) TestVersion + decodeTerm (CBOR.TInt 1) = Right TestVersion + decodeTerm (CBOR.TInt n) = Left ( T.pack "decode TestVersion: unknown tag: " + <> T.pack (show n) + , Just n + ) + decodeTerm _ = Left ( T.pack "decode TestVersion: unexpected term" + , Nothing) + +testVersionCodecCBORTerm + :: TestVersion + -> CodecCBORTerm Text TestVersionData +testVersionCodecCBORTerm !_ = + CodecCBORTerm { encodeTerm = encodeTerm, decodeTerm = decodeTerm } + where + encodeTerm :: TestVersionData -> CBOR.Term + encodeTerm TestVersionData {networkMagic} + = CBOR.TList + [ CBOR.TInt (fromIntegral $ unNetworkMagic networkMagic) + ] + + decodeTerm :: CBOR.Term -> Either Text TestVersionData + decodeTerm (CBOR.TList [CBOR.TInt x]) + | x >= 0 + , x <= 0xffffffff + = Right + TestVersionData { + networkMagic = NetworkMagic (fromIntegral x) + } + | otherwise + = Left $ T.pack $ "networkMagic out of bound: " <> show x + decodeTerm t + = Left $ T.pack $ "unknown encoding: " ++ show t + -- -- The list of all tests @@ -167,20 +245,16 @@ demo chain0 updates = withIOManager $ \iocp -> do HandshakeArguments { haHandshakeTracer = nullTracer, haBearerTracer = nullTracer, - haHandshakeCodec = nodeToNodeHandshakeCodec, - haVersionDataCodec = cborTermVersionDataCodec nodeToNodeCodecCBORTerm, + haHandshakeCodec = handshakeCodec, + haVersionDataCodec = cborTermVersionDataCodec testVersionCodecCBORTerm, haAcceptVersion = acceptableVersion, haQueryVersion = queryVersion, haTimeLimits = noTimeLimitsHandshake } (simpleSingletonVersions - (maxBound :: NodeToNodeVersion) - (NodeToNodeVersionData { - networkMagic = NetworkMagic 0, - diffusionMode = InitiatorAndResponderDiffusionMode, - peerSharing = PeerSharingDisabled, - query = False }) + (maxBound :: TestVersion) + TestVersionData { networkMagic = NetworkMagic 0 } (\_ -> SomeResponderApplication responderApp)) $ \producerAddress' _ -> do withAsync @@ -188,20 +262,16 @@ demo chain0 updates = withIOManager $ \iocp -> do (socketSnocket iocp) makeSocketBearer ConnectToArgs { - ctaHandshakeCodec = nodeToNodeHandshakeCodec, + ctaHandshakeCodec = handshakeCodec, ctaHandshakeTimeLimits = noTimeLimitsHandshake, - ctaVersionDataCodec = cborTermVersionDataCodec nodeToNodeCodecCBORTerm, + ctaVersionDataCodec = cborTermVersionDataCodec testVersionCodecCBORTerm, ctaConnectTracers = nullNetworkConnectTracers, ctaHandshakeCallbacks = HandshakeCallbacks acceptableVersion queryVersion } (`configureSocket` Nothing) (simpleSingletonVersions - (maxBound :: NodeToNodeVersion) - (NodeToNodeVersionData { - networkMagic = NetworkMagic 0, - diffusionMode = InitiatorOnlyDiffusionMode, - peerSharing = PeerSharingDisabled, - query = False }) + (maxBound :: TestVersion) + TestVersionData { networkMagic = NetworkMagic 0 } (\_ -> initiatorApp)) (Just consumerAddress) producerAddress') diff --git a/ouroboros-network/tests/lib/Ouroboros/Network/BlockFetch/Examples.hs b/ouroboros-network/tests/lib/Ouroboros/Network/BlockFetch/Examples.hs index 28ca67ed770..30a9cfde718 100644 --- a/ouroboros-network/tests/lib/Ouroboros/Network/BlockFetch/Examples.hs +++ b/ouroboros-network/tests/lib/Ouroboros/Network/BlockFetch/Examples.hs @@ -39,8 +39,6 @@ import Ouroboros.Network.Block import Network.TypedProtocol.Peer.Client -import Cardano.Network.NodeToNode (NodeToNodeVersion (..)) - import Ouroboros.Network.AnchoredFragment qualified as AF import Ouroboros.Network.BlockFetch import Ouroboros.Network.BlockFetch.Client @@ -59,6 +57,10 @@ import Ouroboros.Network.BlockFetch.Decision.Trace (TraceDecisionEvent) import Ouroboros.Network.Mock.ConcreteBlock +data NodeToNodeVersion = NodeToNodeTestVersion + deriving (Eq, Ord, Bounded, Enum, Show) + + -- | Run a single block fetch protocol until the chain is downloaded. -- blockFetchExample0 :: forall m. diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs index 18c5c67ad6c..4bccc937775 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/BlockFetch.hs @@ -35,8 +35,6 @@ import Control.Monad.Class.MonadTimer.SI import Control.Monad.IOSim import Control.Tracer (Tracer (Tracer), contramap, nullTracer) -import Cardano.Network.NodeToNode.Version (NodeToNodeVersion) - import Ouroboros.Network.ControlMessage (ControlMessage (..)) import Ouroboros.Network.DeltaQ --TODO: could re-export some of the trace types from more convenient places: @@ -94,6 +92,9 @@ tests = testGroup "BlockFetch" ] +data NodeToNodeVersion = TestVersion + deriving (Eq, Ord, Show, Enum, Bounded) + -- -- Properties -- diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs index 2632c041208..a8f7ad26fc7 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node.hs @@ -32,7 +32,6 @@ module Test.Ouroboros.Network.Diffusion.Node , config_REPROMOTE_DELAY -- * re-exports , Node.BlockGeneratorArgs (..) - , Node.LimitsAndTimeouts (..) , Node.randomBlockGenerationArgs , Node.ntnAddrToRelayAccessPoint ) where @@ -61,9 +60,7 @@ import Data.Text (Text) import Data.Text qualified as Text import Data.Void (Void) import Network.DNS (Domain, TYPE) -import System.Random (StdGen, mkStdGen, split) - -import Cardano.Network.Diffusion.Configuration qualified as Cardano +import System.Random (StdGen, split) import Ouroboros.Network.Mux (noBindForkPolicy) import Ouroboros.Network.Protocol.Handshake (HandshakeArguments (..)) @@ -98,12 +95,11 @@ import Ouroboros.Network.PeerSelection.LedgerPeers (NumberOfPeers) import Ouroboros.Network.PeerSelection.LedgerPeers.Type (LedgerPeersConsensusInterface, LedgerPeersKind, UseLedgerPeers) import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise (..)) -import Ouroboros.Network.PeerSelection.PeerMetric (PeerMetrics, - PeerMetricsConfiguration (..), newPeerMetric) import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) import Ouroboros.Network.PeerSelection.PeerStateActions (PeerConnectionHandle) import Ouroboros.Network.PeerSelection.PublicRootPeers (PublicRootPeers) -import Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint) +import Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint, + SRVPrefix) import Ouroboros.Network.PeerSelection.RootPeersDNS (DNSLookupType (..), DNSSemaphore, PeerActionsDNS) import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency, @@ -115,8 +111,7 @@ import Ouroboros.Network.Snocket (MakeBearer, Snocket, TestAddress (..), import Ouroboros.Network.TxSubmission.Inbound.V2.Policy (TxDecisionPolicy) import Ouroboros.Network.TxSubmission.Inbound.V2.Registry (decisionLogicThreads) -import Ouroboros.Network.TxSubmission.Inbound.V2.Types (TraceTxLogic, - TraceTxSubmissionInbound) +import Ouroboros.Network.TxSubmission.Inbound.V2.Types (TraceTxLogic) import Simulation.Network.Snocket (AddressType (..), FD) @@ -126,7 +121,7 @@ import Test.Ouroboros.Network.Diffusion.Node.ChainDB (addBlock, import Test.Ouroboros.Network.Diffusion.Node.Kernel (NodeKernel (..), NtCAddr, NtCVersion, NtCVersionData, NtNAddr, NtNVersion, NtNVersionData (..)) import Test.Ouroboros.Network.Diffusion.Node.Kernel qualified as Node -import Test.Ouroboros.Network.Diffusion.Node.MiniProtocols qualified as Node +-- import Test.Ouroboros.Network.Diffusion.Node.MiniProtocols qualified as Node import Test.Ouroboros.Network.PeerSelection.RootPeersDNS (DNSLookupDelay, DNSTimeout, DomainAccessPoint (..), MockDNSLookupResult, mockDNSActions) @@ -147,6 +142,7 @@ data Interfaces extraAPI m = Interfaces , iLedgerPeersConsensusInterface :: LedgerPeersConsensusInterface extraAPI m , iConnStateIdSupply :: ConnStateIdSupply m + , iSRVPrefix :: SRVPrefix } type NtNFD m = FD m NtNAddr @@ -179,8 +175,9 @@ data Arguments extraChurnArgs extraFlags m = Arguments } run :: forall extraState extraDebugState extraAPI - extraPeers extraFlags extraChurnArgs extraCounters - exception resolver m. + extraPeers extraFlags extraChurnArgs + extraCounters extraTrace + exception resolver m. ( Alternative (STM m) , MonadAsync m , MonadDelay m @@ -206,7 +203,6 @@ run :: forall extraState extraDebugState extraAPI , forall a. Semigroup a => Semigroup (m a) ) => Node.BlockGeneratorArgs Block StdGen - -> Node.LimitsAndTimeouts BlockHeader Block -> Interfaces extraAPI m -> Arguments extraChurnArgs extraFlags m -> extraState @@ -220,6 +216,7 @@ run :: forall extraState extraDebugState extraAPI extraPeers extraAPI extraCounters + extraTrace NtNAddr (PeerConnectionHandle muxMode responderCtx NtNAddr ntnVersionData bytes m a b) @@ -251,29 +248,33 @@ run :: forall extraState extraDebugState extraAPI extraPeers extraAPI extraCounters + extraTrace NtNAddr -> m Void) -> Diffusion.Tracers NtNAddr NtNVersion NtNVersionData NtCAddr NtCVersion NtCVersionData extraState extraDebugState extraFlags - extraPeers extraCounters m + extraPeers extraCounters extraTrace m -> Tracer m (TraceLabelPeer NtNAddr (TraceFetchClientState BlockHeader)) - -> Tracer m (TraceTxSubmissionInbound Int (Tx Int)) -> Tracer m (TraceTxLogic NtNAddr Int (Tx Int)) + -> ( NodeKernel BlockHeader Block StdGen Int m + -> StdGen + -> Diffusion.Applications NtNAddr NtNVersion NtNVersionData + NtCAddr NtCVersion NtCVersionData + m () + ) -> m Void -run blockGeneratorArgs limits ni na +run blockGeneratorArgs ni na emptyExtraState emptyExtraCounters extraPeersAPI psArgs psToExtraCounters toExtraPeers requestPublicRootPeers peerChurnGovernor - tracers tracerBlockFetch tracerTxSubmissionInbound - tracerTxLogic = do + tracers tracerBlockFetch + tracerTxLogic mkApps = do labelThisThread ("node-" ++ Node.ppNtNAddr (aIPAddress na)) Node.withNodeKernelThread (aIPAddress na) blockGeneratorArgs (aTxs na) $ \ nodeKernel nodeKernelThread -> do dnsTimeoutScriptVar <- newTVarIO (aDNSTimeoutScript na) dnsLookupDelayScriptVar <- newTVarIO (aDNSLookupDelayScript na) - peerMetrics <- newPeerMetric PeerMetricsConfiguration { maxEntriesToTrack = 180 } - policyStdGenVar <- newTVarIO (mkStdGen 12) let -- diffusion interfaces interfaces :: Diffusion.Interfaces (NtNFD m) NtNAddr @@ -343,25 +344,15 @@ run blockGeneratorArgs limits ni na , Diffusion.daRequestPublicRootPeers = Just requestPublicRootPeers , Diffusion.daPeerChurnGovernor = peerChurnGovernor , Diffusion.daExtraChurnArgs = aExtraChurnArgs na - , Diffusion.daSRVPrefix = Cardano.srvPrefix + , Diffusion.daSRVPrefix = iSRVPrefix ni } - apps = Node.applications - (aDebugTracer na) - tracerTxSubmissionInbound - tracerTxLogic - nodeKernel - Node.cborCodecs - limits - (appArgs peerMetrics policyStdGenVar) - blockHeader - withAsync (Diffusion.runM interfaces tracers extraParameters (mkArgs (nkPublicPeerSelectionVar nodeKernel)) - apps) + (mkApps nodeKernel keepAliveStdGen)) $ \ diffusionThread -> withAsync (blockFetch nodeKernel) $ \blockFetchLogicThread -> @@ -501,22 +492,6 @@ run blockGeneratorArgs limits ni na , Diffusion.dcEgressPollInterval = 0.001 } - appArgs :: PeerMetrics m NtNAddr - -> StrictTVar m StdGen - -> Node.AppArgs BlockHeader Block m - appArgs peerMetrics stdGenVar = Node.AppArgs - { Node.aaKeepAliveStdGen = keepAliveStdGen - , Node.aaPolicyStdGen = stdGenVar - , Node.aaDiffusionMode = aDiffusionMode na - , Node.aaKeepAliveInterval = aKeepAliveInterval na - , Node.aaPingPongInterval = aPingPongInterval na - , Node.aaShouldChainSyncExit = aShouldChainSyncExit na - , Node.aaChainSyncEarlyExit = aChainSyncEarlyExit na - , Node.aaPeerSharing = aPeerSharing na - , Node.aaPeerMetrics = peerMetrics - , Node.aaTxDecisionPolicy = aTxDecisionPolicy na - } - --- Utils ntnToIPv4 :: NtNAddr -> Maybe NtNAddr diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs index 8aa1f43ccc5..6ab63cd8955 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/Diffusion/Node/Kernel.hs @@ -61,8 +61,6 @@ import System.Random qualified as Random import Network.Socket (PortNumber) -import Cardano.Network.NodeToNode () - import Ouroboros.Network.AnchoredFragment (Anchor (..)) import Ouroboros.Network.Block (HasFullHeader, SlotNo) import Ouroboros.Network.Block qualified as Block diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/LedgerPeers.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/LedgerPeers.hs index 619ac0795d6..9bedaa6b23f 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/LedgerPeers.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/LedgerPeers.hs @@ -42,7 +42,6 @@ import System.Random import Network.DNS (Domain) -import Cardano.Network.Diffusion.Configuration qualified as Cardano (srvPrefix) import Cardano.Slotting.Slot (SlotNo (..), WithOrigin (..)) import Ouroboros.Network.PeerSelection.LedgerPeers import Ouroboros.Network.PeerSelection.LedgerPeers.Utils @@ -69,9 +68,8 @@ tests = testGroup "Ouroboros.Network.LedgerPeers" type ExtraTestInterface = () - cardanoSRVPrefix :: SRVPrefix -cardanoSRVPrefix = Cardano.srvPrefix +cardanoSRVPrefix = "_cardano._tcp" data StakePool = StakePool { spStake :: !Word64 diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs index 3da7af42e00..f4489ea17d9 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs @@ -24,7 +24,6 @@ import Data.Hashable import Data.IP qualified as IP import Data.Word (Word16, Word32, Word64) -import Cardano.Network.Diffusion.Configuration qualified as Cardano (srvPrefix) import Cardano.Slotting.Slot (SlotNo (..)) import Ouroboros.Network.DiffusionMode @@ -42,6 +41,8 @@ import Test.Ouroboros.Network.Utils (ShrinkCarefully, prop_shrink_nonequal, prop_shrink_valid) import Test.QuickCheck +srvPrefix :: SRVPrefix +srvPrefix = "_cardano._tcp" -- -- QuickCheck instances @@ -146,7 +147,7 @@ instance Arbitrary PortNumber where . fromIntegral @PortNumber @Word16 instance Arbitrary RelayAccessPoint where - arbitrary = prefixLedgerRelayAccessPoint Cardano.srvPrefix <$> arbitrary + arbitrary = prefixLedgerRelayAccessPoint srvPrefix <$> arbitrary instance Arbitrary LedgerRelayAccessPoint where arbitrary = diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV1.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV1.hs index 0ccfd07ce14..bc154f5762b 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV1.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV1.hs @@ -32,8 +32,6 @@ import Data.List (intercalate, nubBy) import Data.Maybe (fromMaybe) import Data.Word (Word16) -import Cardano.Network.NodeToNode (NodeToNodeVersion (..)) - import Ouroboros.Network.Channel import Ouroboros.Network.ControlMessage (ControlMessage (..), ControlMessageSTM) import Ouroboros.Network.Driver @@ -58,6 +56,9 @@ tests = testGroup "AppV1" [ testProperty "txSubmission" prop_txSubmission ] +data TestVersion = TestVersion + deriving (Eq, Ord, Bounded, Enum, Show) + txSubmissionSimulation :: forall m txid. ( MonadAsync m @@ -124,7 +125,7 @@ txSubmissionSimulation tracer maxUnacked outboundTxs nullTracer maxUnacked (getMempoolReader outboundMempool) - (maxBound :: NodeToNodeVersion) + (maxBound :: TestVersion) controlMessageSTM inboundPeer :: Mempool m (Tx txid) -> TxSubmissionServerPipelined txid (Tx txid) m () @@ -135,7 +136,7 @@ txSubmissionSimulation tracer maxUnacked outboundTxs maxUnacked (getMempoolReader inboundMempool) (getMempoolWriter inboundMempool) - (maxBound :: NodeToNodeVersion) + (maxBound :: TestVersion) prop_txSubmission :: Positive Word16 -> NonEmptyList (Tx Int) diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV2.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV2.hs index d14665d5ab7..c12e9ca59dd 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV2.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/TxSubmission/AppV2.hs @@ -44,8 +44,6 @@ import Data.Set qualified as Set import Data.Typeable (Typeable) import System.Random (mkStdGen) -import Cardano.Network.NodeToNode (NodeToNodeVersion (..)) - import Ouroboros.Network.Channel import Ouroboros.Network.ControlMessage (ControlMessage (..), ControlMessageSTM) import Ouroboros.Network.Driver @@ -78,6 +76,9 @@ tests = testGroup "AppV2" prop_sharedTxStateInvariant ] +data TestVersion = TestVersion + deriving (Eq, Ord, Bounded, Enum, Show) + data TxSubmissionState = TxSubmissionState { peerMap :: Map Int ( [Tx Int] @@ -185,7 +186,7 @@ runTxSubmission tracer tracerTxLogic st0 txDecisionPolicy = do (NumTxIdsToAck $ getNumTxIdsToReq $ maxUnacknowledgedTxIds txDecisionPolicy) (getMempoolReader mempool) - (maxBound :: NodeToNodeVersion) + (maxBound :: TestVersion) ctrlMsgSTM runPeerWithLimits (("OUTBOUND " ++ show addr,) `contramap` tracer) txSubmissionCodec2 diff --git a/ouroboros-network/tests/sim/Main.hs b/ouroboros-network/tests/sim/Main.hs index 5340b349851..20deda446d9 100644 --- a/ouroboros-network/tests/sim/Main.hs +++ b/ouroboros-network/tests/sim/Main.hs @@ -3,20 +3,12 @@ module Main (main) where import Main.Utf8 (withUtf8) import Test.Tasty -import Test.Cardano.Network.OrphanInstances.Tests qualified (tests) - import Test.ChainProducerState qualified (tests) import Test.Ouroboros.Network.BlockFetch qualified (tests) -import Test.Ouroboros.Network.Diffusion.Policies qualified (tests) -import Test.Ouroboros.Network.Diffusion.Testnet.Cardano qualified (tests) import Test.Ouroboros.Network.KeepAlive qualified (tests) import Test.Ouroboros.Network.LedgerPeers qualified (tests) import Test.Ouroboros.Network.MockNode qualified (tests) -import Test.Ouroboros.Network.PeerSelection qualified (tests) -import Test.Ouroboros.Network.PeerSelection.Cardano.LocalRootPeers qualified -import Test.Ouroboros.Network.PeerSelection.Cardano.MockEnvironment qualified -import Test.Ouroboros.Network.PeerSelection.Cardano.PublicRootPeers qualified import Test.Ouroboros.Network.PeerSelection.KnownPeers qualified import Test.Ouroboros.Network.PeerSelection.LocalRootPeers qualified import Test.Ouroboros.Network.PeerSelection.PeerMetric qualified @@ -28,15 +20,11 @@ main = withUtf8 $ defaultMain tests tests :: TestTree tests = - testGroup "ouroboros-network:sim-tests" + testGroup "ouroboros-network-sim-tests" -- data structures [ Test.ChainProducerState.tests - -- cardano - , Test.Cardano.Network.OrphanInstances.Tests.tests - -- network logic - , Test.Ouroboros.Network.Diffusion.Policies.tests , Test.Ouroboros.Network.LedgerPeers.tests , Test.Ouroboros.Network.BlockFetch.tests , Test.Ouroboros.Network.KeepAlive.tests @@ -45,13 +33,6 @@ tests = , Test.Ouroboros.Network.PeerSelection.LocalRootPeers.tests , Test.Ouroboros.Network.PeerSelection.PeerMetric.tests , Test.Ouroboros.Network.PeerSelection.RootPeersDNS.tests - , Test.Ouroboros.Network.PeerSelection.tests - - -- cardano specific logic - , Test.Ouroboros.Network.Diffusion.Testnet.Cardano.tests - , Test.Ouroboros.Network.PeerSelection.Cardano.LocalRootPeers.tests - , Test.Ouroboros.Network.PeerSelection.Cardano.MockEnvironment.tests - , Test.Ouroboros.Network.PeerSelection.Cardano.PublicRootPeers.tests -- pseudo system-level , Test.Ouroboros.Network.MockNode.tests From 53ad92506009ea6ebc05488f6ce4cdeb3d8d51b6 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Thu, 18 Sep 2025 15:26:23 +0200 Subject: [PATCH 13/24] Updated nix & GHA --- .github/workflows/build.yml | 48 +++++++++++++++++--------- nix/ouroboros-network.nix | 18 +++++----- scripts/ci/cabal.project.local.Linux | 8 ++--- scripts/ci/cabal.project.local.Windows | 13 +++---- scripts/ci/cabal.project.local.macOS | 4 +-- scripts/ci/cabal.project.nightly.Linux | 14 +++----- scripts/ci/check-stylish-ignore | 6 ++-- scripts/ci/run-stylish-haskell.sh | 5 +-- 8 files changed, 61 insertions(+), 55 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32c11f51105..86a63151df2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,14 +97,11 @@ jobs: path: ${{ steps.setup-haskell.outputs.cabal-store }} key: ${{ steps.cache-dependencies.outputs.cache-primary-key }} - - name: Build projects [build] + - name: Build all packages run: cabal build all -j # Test network packages - - name: ouroboros-network-api [test] - run: cabal run ouroboros-network-api:test - - name: ntp-client [test] run: cabal run ntp-client:test -- +RTS -maxN2 -RTS @@ -115,26 +112,45 @@ jobs: # TODO: issue #4635 to enable `+RTS -N` run: cabal run network-mux:test - - name: ourobors-network-testing [test] - run: cabal run ouroboros-network-testing:test -- +RTS -maxN2 -RTS + - name: ouroboros-network [api-tests] + run: cabal run ouroboros-network:api-tests + + - name: ourobors-network [tests-lib-tests] + run: cabal run ouroboros-network:tests-lib-tests -- +RTS -maxN2 -RTS - - name: ourobors-network-framework [io-tests] + - name: ourobors-network [framework-io-tests] # TODO: enable `+RTS -N` - run: cabal run ouroboros-network-framework:io-tests + run: cabal run ouroboros-network:framework-io-tests + + - name: ourobors-network [framework-sim-tests] + if: runner.os != 'Windows' + run: cabal run ouroboros-network:framework-sim-tests -- +RTS -maxN2 -RTS + + - name: ouroboros-network [protocols-tests] + run: cabal run ouroboros-network:protocols-tests -- +RTS -maxN2 -RTS - - name: ourobors-network-framework [sim-tests] + - name: ouroboros-network [ouroboros-network-io-tests] + run: cabal run ouroboros-network:ouroboros-network-io-tests -- +RTS -maxN2 -RTS + + - name: ouroboros-network [ouroboros-network-sim-tests] if: runner.os != 'Windows' - run: cabal run ouroboros-network-framework:sim-tests -- +RTS -maxN2 -RTS + run: cabal run ouroboros-network:ouroboros-network-sim-tests -- +RTS -maxN2 -RTS - - name: ouroboros-network-protocols [test] - run: cabal run ouroboros-network-protocols:test -- +RTS -maxN2 -RTS + - name: cardano-diffusion:protocols-tests + if: runner.os != 'Windows' + run: cabal run cardano-diffusion:protocols-tests -- +RTS -maxN2 -RTS - - name: ouroboros-network [io-tests] - run: cabal run ouroboros-network:io-tests -- +RTS -maxN2 -RTS + - name: cardano-diffusion:api-tests + if: runner.os != 'Windows' + run: cabal run cardano-diffusion:api-tests -- +RTS -maxN2 -RTS + + - name: cardano-diffusion:protocols-tests + if: runner.os != 'Windows' + run: cabal run cardano-diffusion:protocols-tests -- +RTS -maxN2 -RTS - - name: ouroboros-network [sim-tests] + - name: cardano-diffusion:cardano-diffusion-sim-test if: runner.os != 'Windows' - run: cabal run ouroboros-network:sim-tests -- +RTS -maxN2 -RTS + run: cabal run cardano-diffusion:cardano-diffusion-sim-tests -- +RTS -maxN2 -RTS - name: dmq-node [test] run: cabal run dmq-node:dmq-test -- +RTS -maxN2 -RTS diff --git a/nix/ouroboros-network.nix b/nix/ouroboros-network.nix index f4d86a894af..127176efa3d 100644 --- a/nix/ouroboros-network.nix +++ b/nix/ouroboros-network.nix @@ -102,23 +102,25 @@ let doCheck = !pkgs.stdenv.hostPlatform.isWindows; # pkgs are instantiated for the host platform - packages.ouroboros-network-protocols.components.tests.cddl.build-tools = [ pkgs.cddl pkgs.cbor-diag pkgs.cddlc ]; - packages.ouroboros-network-protocols.components.tests.cddl.preCheck = "export HOME=`pwd`"; + packages.cardano-diffusion.components.tests.protocols-cddl.build-tools = [ pkgs.cddl pkgs.cbor-diag pkgs.cddlc ]; + packages.cardano-diffusion.components.tests.protocols-cddl.preCheck = "export HOME=`pwd`"; + # note: protocols-cddl is disabled on Windows in ./scripts/ci/cabal.project.local.Windows packages.dmq-node.components.tests.dmq-cddl.build-tools = [ pkgs.cddl pkgs.cbor-diag pkgs.cddlc ]; packages.dmq-node.components.tests.dmq-cddl.preCheck = "export HOME=`pwd`"; - packages.ouroboros-network-framework.components.tests.sim-tests.doCheck = onLinux; - packages.ouroboros-network.components.tests.sim-tests.doCheck = onLinux; + # pkgs are disabled since we don't have enough CPU bandwidth on MacOS machines + packages.ouroboros-network.components.tests.framework-sim-tests.doCheck = onLinux; + packages.ouroboros-network.components.tests.ouroboros-network-sim-tests.doCheck = onLinux; packages.dmq-node.components.tests.dmq-test.preCheck = if buildSystem == "x86_64-linux" then "export GHCRTS=-M1600M" else ""; packages.network-mux.components.tests.test.preCheck = if buildSystem == "x86_64-linux" then "export GHCRTS=-M800M" else ""; - packages.ouroboros-network-protocols.components.tests.test.preCheck = + packages.ouroboros-network.components.tests.protocols-test.preCheck = if buildSystem == "x86_64-linux" then "export GHCRTS=-M800M" else ""; - packages.ouroboros-network.components.tests.sim-tests.preCheck = + packages.cardano-diffusion.components.tests.cardano-diffusion-sim-tests.preCheck = if buildSystem == "x86_64-linux" then "export GHCRTS=-M7000M" else ""; }) ({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isWindows { @@ -128,8 +130,8 @@ let # rubby fails to build with musl, hence we disable cddl tests packages.dmq-node.components.tests.dmq-cddl.build-tools = lib.mkForce [ ]; packages.dmq-node.components.tests.dmq-cddl.doCheck = lib.mkForce false; - packages.ouroboros-network-protocols.components.tests.cddl.build-tools = lib.mkForce [ ]; - packages.ouroboros-network-protocols.components.tests.cddl.doCheck = lib.mkForce false; + packages.cardano-diffusion.components.tests.protocols-cddl.build-tools = lib.mkForce [ ]; + packages.cardano-diffusion.components.tests.protocols-cddl.doCheck = lib.mkForce false; packages.dmq-node.ghcOptions = with pkgs; [ "-L${lib.getLib static-gmp}/lib" "-L${lib.getLib static-libsodium-vrf}/lib" diff --git a/scripts/ci/cabal.project.local.Linux b/scripts/ci/cabal.project.local.Linux index f27cf289107..864973f2fc6 100644 --- a/scripts/ci/cabal.project.local.Linux +++ b/scripts/ci/cabal.project.local.Linux @@ -16,8 +16,8 @@ package network-mux flags: +ipv6 -- IPv6 tests are DISABLED -package ouroboros-network-framework - flags: -ipv6 +package ouroboros-network + flags: +asserts -ipv6 -package ouroboros-network-protocols - flags: +cddl +package cardano-diffusion + flags: +asserts +cddl diff --git a/scripts/ci/cabal.project.local.Windows b/scripts/ci/cabal.project.local.Windows index 7e6ce4a764a..af847f4bb59 100644 --- a/scripts/ci/cabal.project.local.Windows +++ b/scripts/ci/cabal.project.local.Windows @@ -17,19 +17,16 @@ package ntp-client package network-mux flags: -ipv6 -package ouroboros-network-api - flags: +asserts - -package ouroboros-network-framework - flags: -ipv6 +package ouroboros-network + flags: +asserts -ipv6 -- -- cddl is disabled on Windows due to missing build tool support in cross -- compilation -- -package ouroboros-network-protocols - flags: -cddl - package dmq-node flags: -cddl + +package cardano-diffusion + flags: +asserts -cddl diff --git a/scripts/ci/cabal.project.local.macOS b/scripts/ci/cabal.project.local.macOS index 9c4695d67d0..ae6473f00aa 100644 --- a/scripts/ci/cabal.project.local.macOS +++ b/scripts/ci/cabal.project.local.macOS @@ -17,8 +17,8 @@ package ouroboros-network-api -- IPv6 tests are DISABLED -package ouroboros-network-framework +package ouroboros-network flags: -ipv6 -package ouroboros-network-protocols +package cardano-diffusion flags: +cddl diff --git a/scripts/ci/cabal.project.nightly.Linux b/scripts/ci/cabal.project.nightly.Linux index 34ae64b581d..20a172f9257 100644 --- a/scripts/ci/cabal.project.nightly.Linux +++ b/scripts/ci/cabal.project.nightly.Linux @@ -15,15 +15,9 @@ package ntp-client package network-mux flags: +ipv6 -package ouroboros-network-api - flags: +asserts - -package ouroboros-network-testing - flags: +nightly - -- IPv6 tests are DISABLED -package ouroboros-network-framework - flags: -ipv6 +package ouroboros-network + flags: +asserts -ipv6 -package ouroboros-network-protocols - flags: +cddl +package cardano-diffusion + flags: +asserts +cddl diff --git a/scripts/ci/check-stylish-ignore b/scripts/ci/check-stylish-ignore index af52d6153d3..e3661c4a837 100644 --- a/scripts/ci/check-stylish-ignore +++ b/scripts/ci/check-stylish-ignore @@ -1,7 +1,7 @@ */Setup.hs -ouroboros-network-api/src/Ouroboros/Network/Protocol/Type.hs -ouroboros-network/src/Ouroboros/Network/BlockFetch/Decision/Genesis.hs -ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Types.hs +ouroboros-network/api/lib/Ouroboros/Network/Protocol/Type.hs +ouroboros-network/lib/Ouroboros/Network/BlockFetch/Decision/Genesis.hs +ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor/Types.hs network-mux/src/Network/Mux/TCPInfo.hs network-mux/src/Network/Mux/Bearer.hs network-mux/src/Network/Mux/Bearer/Pipe.hs diff --git a/scripts/ci/run-stylish-haskell.sh b/scripts/ci/run-stylish-haskell.sh index ce29d491143..d27be8df9c0 100755 --- a/scripts/ci/run-stylish-haskell.sh +++ b/scripts/ci/run-stylish-haskell.sh @@ -63,11 +63,8 @@ done FD_OPTS="-e hs --ignore-file ./scripts/ci/check-stylish-ignore -X stylish-haskell $STYLISH_HASKELL_ARGS" fd . './network-mux' $FD_OPTS -fd . './ouroboros-network-api' $FD_OPTS -fd . './ouroboros-network-framework' $FD_OPTS -fd . './ouroboros-network-mock' $FD_OPTS -fd . './ouroboros-network-protocols' $FD_OPTS fd . './ouroboros-network' $FD_OPTS +fd . './cardano-diffusion' $FD_OPTS fd . './cardano-client' $FD_OPTS fd . './dmq-node' $FD_OPTS From ffa90635bfe4f23c3e0a1b453e2a3889afa985a8 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 24 Sep 2025 20:29:58 +0200 Subject: [PATCH 14/24] peer-selection: reorganised exports, part 1 Expanded `Ouroboros.Network.PeerSelection` module to simplify imports in downstream libraries. --- .../Cardano/Network/PeerSelection/Churn.hs | 11 ++-- .../Network/PeerSelection/Governor/Monitor.hs | 2 +- .../PeerSelection/PeerSelectionActions.hs | 6 +-- .../PeerSelection/State/LocalRootPeers.hs | 20 ++++---- .../Network/Diffusion/Testnet/Simulation.hs | 7 +-- .../lib/Test/Cardano/Network/PeerSelection.hs | 2 +- .../lib/Ouroboros/Network/Diffusion.hs | 50 +++++++++---------- .../Ouroboros/Network/Diffusion/Topology.hs | 5 +- .../lib/Ouroboros/Network/Diffusion/Types.hs | 3 +- .../lib/Ouroboros/Network/PeerSelection.hs | 42 +++++++++++----- .../Ouroboros/Network/PeerSelection/Churn.hs | 2 +- .../PeerSelection/PeerSelectionActions.hs | 6 +-- .../PeerSelection/State/LocalRootPeers.hs | 6 +-- .../Ouroboros/Network/OrphanInstances.hs | 22 ++------ .../Network/PeerSelection/Instances.hs | 9 ++-- .../Network/PeerSelection/RootPeersDNS.hs | 3 -- 16 files changed, 98 insertions(+), 98 deletions(-) diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs index 532c55be583..8cda2a0d819 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs @@ -133,11 +133,12 @@ peerChurnGovernor PeerChurnArgs { pcaRng = inRng, pcaPeerSelectionVar = peerSelectionVar, pcaReadCounters = readCounters, - getLedgerStateCtx = LedgerPeersConsensusInterface { - lpExtraAPI = Cardano.LedgerPeersConsensusInterface { - Cardano.readFetchMode, - Cardano.getLedgerStateJudgement - } + getLedgerPeersAPI = + LedgerPeersConsensusInterface { + lpExtraAPI = Cardano.LedgerPeersConsensusInterface { + Cardano.readFetchMode, + Cardano.getLedgerStateJudgement + } }, getLocalRootHotTarget, pcaPeerSelectionTargets = peerSelectionTargets, diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs index 4205851bdb9..138ce6cd744 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs @@ -645,7 +645,7 @@ waitForSystemToQuiesce st@PeerSelectionState{ , not hasOnlyBootstrapPeers -- Are the local root peers all trustable? , all (\case - LocalRootConfig { extraFlags = IsTrustable } + LocalRootConfig { extraLocalRootFlags = IsTrustable } -> True _ -> False ) diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs index 6dc33ffef76..50e8dfc8f49 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs @@ -72,12 +72,12 @@ requestPublicRootPeers $ requiresBootstrapPeers <$> useBootstrapped <*> getLedgerStateJudgement if usingBootstrapPeers - then do + then do -- If the ledger state is in sensitive state we should get trustable peers. (bootstrapPeers, dt) <- requestConfiguredBootstrapPeers n pure (Cardano.PublicRootPeers.fromBootstrapPeers bootstrapPeers, dt) - else do - Ouroboros.requestPublicRootPeers + else do + Ouroboros.requestPublicRootPeersImpl publicTracer readPublicRootPeers pad diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/State/LocalRootPeers.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/State/LocalRootPeers.hs index 2cac03ffbe3..9855a9c9139 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/State/LocalRootPeers.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/State/LocalRootPeers.hs @@ -19,18 +19,20 @@ clampToTrustable :: Ord peeraddr => LocalRootPeers PeerTrustable peeraddr -> LocalRootPeers PeerTrustable peeraddr clampToTrustable (LocalRootPeers m gs) = - let trustedMap = Map.filter (\LocalRootConfig { extraFlags } -> case extraFlags of - IsTrustable -> True - IsNotTrustable -> False + let trustedMap = Map.filter (\LocalRootConfig { extraLocalRootFlags } -> + case extraLocalRootFlags of + IsTrustable -> True + IsNotTrustable -> False ) m in LocalRootPeers trustedMap (trustedGroups gs) where trustedGroups [] = [] trustedGroups ((h, w, g):gss) = - let trusted = Map.filter (\LocalRootConfig { extraFlags } -> case extraFlags of - IsTrustable -> True - IsNotTrustable -> False + let trusted = Map.filter (\LocalRootConfig { extraLocalRootFlags } -> + case extraLocalRootFlags of + IsTrustable -> True + IsNotTrustable -> False ) m trustedSet = Map.keysSet trusted @@ -47,7 +49,7 @@ isPeerTrustable :: Ord peeraddr -> Bool isPeerTrustable peeraddr lrp = case Map.lookup peeraddr (toMap lrp) of - Just LocalRootConfig { extraFlags = IsTrustable } + Just LocalRootConfig { extraLocalRootFlags = IsTrustable } -> True _ -> False @@ -55,8 +57,8 @@ trustableKeysSet :: LocalRootPeers PeerTrustable peeraddr -> Set peeraddr trustableKeysSet (LocalRootPeers m _) = Map.keysSet - . Map.filter (\LocalRootConfig { extraFlags } -> - case extraFlags of + . Map.filter (\LocalRootConfig { extraLocalRootFlags } -> + case extraLocalRootFlags of IsTrustable -> True IsNotTrustable -> False) $ m diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs index 58180dde485..7d27f462176 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs @@ -98,7 +98,6 @@ import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano import Cardano.Network.PeerSelection.Governor.Types qualified as ExtraSizes import Cardano.Network.PeerSelection.PeerSelectionActions (requestPublicRootPeers) -import Ouroboros.Network.PeerSelection.RelayAccessPoint import Ouroboros.Network.Block (BlockNo) import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..), @@ -116,13 +115,9 @@ import Ouroboros.Network.Handshake.Acceptable (Acceptable (acceptableVersion)) import Ouroboros.Network.InboundGovernor (RemoteTransitionTrace) import Ouroboros.Network.InboundGovernor qualified as IG import Ouroboros.Network.Mux (MiniProtocolLimits (..)) -import Ouroboros.Network.PeerSelection hiding (peerChurnGovernor, - requestPublicRootPeers) +import Ouroboros.Network.PeerSelection hiding (requestPublicRootPeers) import Ouroboros.Network.PeerSelection.Governor qualified as Governor import Ouroboros.Network.PeerSelection.LedgerPeers (accPoolStake) -import Ouroboros.Network.PeerSelection.RootPeersDNS -import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency (..), - LocalRootConfig, WarmValency (..)) import Ouroboros.Network.Protocol.BlockFetch.Codec (byteLimitsBlockFetch, timeLimitsBlockFetch) import Ouroboros.Network.Protocol.ChainSync.Codec (byteLimitsChainSync, diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs index 1d01b9b738b..72e0f7d17ba 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs @@ -3726,7 +3726,7 @@ prop_governor_only_bootstrap_peers_in_clean_state env = . selectEnvEvents $ events where - isTrustable LocalRootConfig { extraFlags = IsTrustable } + isTrustable LocalRootConfig { extraLocalRootFlags = IsTrustable } = True isTrustable _ = False diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs index e12035dd1c2..fb44072b467 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs @@ -1,14 +1,14 @@ -{-# LANGUAGE BlockArguments #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DisambiguateRecordFields #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeOperators #-} -- | This module is expected to be imported qualified. -- @@ -70,8 +70,8 @@ import Ouroboros.Network.IOManager import Ouroboros.Network.Mux hiding (MiniProtocol (..)) import Ouroboros.Network.MuxMode import Ouroboros.Network.PeerSelection as PeerSelection -import Ouroboros.Network.PeerSelection.Governor qualified as Governor -import Ouroboros.Network.PeerSelection.RootPeersDNS (PeerActionsDNS (..)) +import Ouroboros.Network.PeerSelection.Churn as PeerSelection +import Ouroboros.Network.PeerSelection.PeerSelectionActions as PeerSelection import Ouroboros.Network.PeerSelection.RootPeersDNS qualified as RootPeersDNS import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Ouroboros.Network.PeerSharing (PeerSharingRegistry (..)) @@ -440,9 +440,9 @@ runM Interfaces localRootsVar <- newTVarIO mempty -- churn will set initial targets - peerSelectionTargetsVar <- newTVarIO Governor.nullPeerSelectionTargets + peerSelectionTargetsVar <- newTVarIO PeerSelection.nullPeerSelectionTargets - countersVar <- newTVarIO (Governor.emptyPeerSelectionCounters daEmptyExtraCounters) + countersVar <- newTVarIO (PeerSelection.emptyPeerSelectionCounters daEmptyExtraCounters) -- Design notes: -- - We split the following code into two parts: @@ -558,7 +558,7 @@ runM Interfaces muxMode socket (ExpandedInitiatorContext ntnAddr m) responderCtx ntnAddr ntnVersionData ntnVersion ByteString m a b - -> (Governor.PeerStateActions + -> (PeerSelection.PeerStateActions ntnAddr (PeerConnectionHandle muxMode responderCtx ntnAddr ntnVersionData ByteString m a b) @@ -625,7 +625,7 @@ runM Interfaces requestPublicRootPeers = case daRequestPublicRootPeers of Nothing -> - PeerSelection.requestPublicRootPeers + PeerSelection.requestPublicRootPeersImpl dtTracePublicRootPeersTracer dcReadPublicRootPeers dnsActions @@ -665,7 +665,7 @@ runM Interfaces m -> m Void peerSelectionGovernor' peerSelectionTracer dbgVar peerSelectionActions = - Governor.peerSelectionGovernor + PeerSelection.peerSelectionGovernor dtTracePeerSelectionTracer peerSelectionTracer dtTracePeerSelectionCounters @@ -697,7 +697,7 @@ runM Interfaces , pcaRng = churnRng , pcaPeerSelectionVar = peerSelectionTargetsVar , pcaReadCounters = readTVar countersVar - , getLedgerStateCtx = daLedgerPeersCtx + , getLedgerPeersAPI = daLedgerPeersCtx , getLocalRootHotTarget = LocalRootPeers.hotTarget . LocalRootPeers.fromGroups @@ -755,13 +755,13 @@ runM Interfaces -- InitiatorOnly mode, run peer selection only: InitiatorOnlyDiffusionMode -> withConnectionManagerInitiatorOnlyMode $ \connectionManager -> do - debugStateVar <- newTVarIO $ Governor.emptyPeerSelectionState fuzzRng daEmptyExtraState mempty + debugStateVar <- newTVarIO $ PeerSelection.emptyPeerSelectionState fuzzRng daEmptyExtraState mempty daInstallSigUSR1Handler connectionManager debugStateVar withPeerStateActions' connectionManager $ \peerStateActions-> withPeerSelectionActions' (return Map.empty) peerStateActions $ - \(ledgerPeersThread, localRootPeersProvider) peerSelectionActions-> + \(ledgerPeersThread, localRootPeersProviderThread) peerSelectionActions-> Async.withAsync (peerSelectionGovernor' dtDebugPeerSelectionInitiatorTracer @@ -771,7 +771,7 @@ runM Interfaces peerChurnGovernor' $ \churnGovernorThread -> -- wait for any thread to fail: snd <$> Async.waitAny - [ledgerPeersThread, localRootPeersProvider, governorThread, churnGovernorThread] + [ledgerPeersThread, localRootPeersProviderThread, governorThread, churnGovernorThread] -- InitiatorAndResponder mode, run peer selection and the server: InitiatorAndResponderDiffusionMode -> do @@ -788,14 +788,14 @@ runM Interfaces -- end, unique to ... withServer sockets inboundInfoChannel \inboundGovernorThread readInboundState connectionManager -> do - debugStateVar <- newTVarIO $ Governor.emptyPeerSelectionState fuzzRng daEmptyExtraState mempty + debugStateVar <- newTVarIO $ PeerSelection.emptyPeerSelectionState fuzzRng daEmptyExtraState mempty daInstallSigUSR1Handler connectionManager debugStateVar withPeerStateActions' connectionManager $ \peerStateActions -> withPeerSelectionActions' (mkInboundPeersMap <$> readInboundState) peerStateActions $ - \(ledgerPeersThread, localRootPeersProvider) peerSelectionActions -> + \(ledgerPeersThread, localRootPeersProviderThread) peerSelectionActions -> Async.withAsync (do labelThisThread "Peer selection governor" @@ -807,7 +807,7 @@ runM Interfaces \churnGovernorThread -> -- wait for any thread to fail: snd <$> Async.waitAny [ ledgerPeersThread - , localRootPeersProvider + , localRootPeersProviderThread , governorThread , churnGovernorThread , inboundGovernorThread diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs index 60af1266634..fd595a7b8cd 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs @@ -10,8 +10,7 @@ import Ouroboros.Network.Diffusion.Configuration (DiffusionMode) import Ouroboros.Network.PeerSelection.LedgerPeers.Type (UseLedgerPeers) import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise) import Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint) -import Ouroboros.Network.PeerSelection.State.LocalRootPeers hiding (extraFlags) -import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LRP +import Ouroboros.Network.PeerSelection.State.LocalRootPeers data NetworkTopology extraConfig extraFlags = NetworkTopology { @@ -85,7 +84,7 @@ producerAddresses NetworkTopology { localRootPeersGroups , LocalRootConfig { diffusionMode = rootDiffusionMode lrp, peerAdvertise, - LRP.extraFlags = extraFlags lrp + extraLocalRootFlags = extraFlags lrp } ) ) diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs index 35923809e8b..cca8c7912dd 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Types.hs @@ -77,8 +77,7 @@ import Ouroboros.Network.Snocket (FileDescriptor, Snocket) import Ouroboros.Network.Socket (SystemdSocketTracer) import Ouroboros.Network.PeerSelection as PeerSelection -import Ouroboros.Network.PeerSelection.Governor.Types -import Ouroboros.Network.PeerSelection.RootPeersDNS +import Ouroboros.Network.PeerSelection.Churn as PeerSelection import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Ouroboros.Network.Server.RateLimiting (AcceptedConnectionsLimit) diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs index 9c204f0f9a2..18bbec01766 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE ExplicitNamespaces #-} module Ouroboros.Network.PeerSelection ( module Governor @@ -10,33 +11,48 @@ module Ouroboros.Network.PeerSelection , module PeerSelection.RelayAccessPoint , module PeerSelection.LedgerPeers , module PeerSelection.PeerMetrics - , module PeerSelection.Churn , module PeerSelection.PeerAdvertise , module PeerSelection.PeerSharing + , module PeerSelection.RootPeersDNS + , module PeerSelection.State.KnownPeers + , module PeerSelection.State.LocalRootPeers ) where -import Ouroboros.Network.PeerSelection.Churn as PeerSelection.Churn --- Only essential `Governor` types. -import Ouroboros.Network.PeerSelection.Governor as Governor - (DebugPeerSelection (..), PeerSelectionActions, - PeerSelectionInterfaces (..), PeerSelectionPolicy (..), - PeerSelectionState, PeerSelectionTargets (..), PeerStateActions, - PickPolicy) +import Ouroboros.Network.PeerSelection.Governor as Governor (PeerSelectionState) +import Ouroboros.Network.PeerSelection.Governor as Governor hiding + (PeerSelectionState (..)) import Ouroboros.Network.PeerSelection.LedgerPeers as PeerSelection.LedgerPeers (AfterSlot (..), IsBigLedgerPeer (..), LedgerPeerSnapshot (..), LedgerPeers (..), LedgerPeersConsensusInterface (..), - LedgerPeersKind (..), NumberOfPeers (..), TraceLedgerPeers (..), - UseLedgerPeers (..), WithLedgerPeersArgs (..), withLedgerPeers) + LedgerPeersKind (..), NumberOfPeers (..), PoolStake (..), + TraceLedgerPeers (..), UseLedgerPeers (..), WithLedgerPeersArgs (..), + withLedgerPeers) import Ouroboros.Network.PeerSelection.PeerAdvertise as PeerSelection.PeerAdvertise import Ouroboros.Network.PeerSelection.PeerMetric as PeerSelection.PeerMetrics (PeerMetrics, PeerMetricsConfiguration (..), ReportPeerMetrics (..), newPeerMetric, newPeerMetric', nullMetric, reportMetric) -import Ouroboros.Network.PeerSelection.PeerSelectionActions as PeerSelection.PeerSelectionActions +-- NOTE: not re-exporting `requestPublicRootPeersImpl` to avoid name clash +-- with the same function in `cardano-diffusion`. +import Ouroboros.Network.PeerSelection.PeerSelectionActions as PeerSelection.PeerSelectionActions hiding + (requestPublicRootPeersImpl) import Ouroboros.Network.PeerSelection.PeerSharing as PeerSelection.PeerSharing import Ouroboros.Network.PeerSelection.PeerStateActions as PeerSelection.PeerStateActions import Ouroboros.Network.PeerSelection.PublicRootPeers as PeerSelection.PublicRootPeers (PublicRootPeers) import Ouroboros.Network.PeerSelection.RelayAccessPoint as PeerSelection.RelayAccessPoint - (IP (..), PortNumber, RelayAccessPoint (..)) +import Ouroboros.Network.PeerSelection.RootPeersDNS as PeerSelection.RootPeersDNS + (DNSorIOError) +import Ouroboros.Network.PeerSelection.RootPeersDNS as PeerSelection.RootPeersDNS hiding + (DNSorIOError (..)) +import Ouroboros.Network.PeerSelection.State.KnownPeers as PeerSelection.State.KnownPeers + (KnownPeerInfo (..)) +import Ouroboros.Network.PeerSelection.State.LocalRootPeers as PeerSelection.State.LocalRootPeers + (HotValency (..), LocalRootConfig (..), LocalRootPeers, + WarmValency (..)) import Ouroboros.Network.PeerSelection.Types as PeerSelection import Ouroboros.Network.PeerSelection.Types as PeerSelection.Types +import Ouroboros.Network.Protocol.PeerSharing.Type as PeerSelection.PeerSharing + (PeerSharingAmount (..), PeerSharingResult (..)) + +-- NOTE: not re-exporting `Ouroboros.Network.PeerSelection.Churn` to avoid name +-- clash with `peerChurnGovernor` in `cardano-diffusion`. diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs index c50a4f95895..d20ba5d6f1e 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs @@ -58,7 +58,7 @@ data PeerChurnArgs m extraArgs extraDebugState extraFlags extraPeers extraAPI ex pcaRng :: StdGen, pcaPeerSelectionVar :: StrictTVar m PeerSelectionTargets, pcaReadCounters :: STM m (PeerSelectionCounters extraCounters), - getLedgerStateCtx :: LedgerPeersConsensusInterface extraAPI m, + getLedgerPeersAPI :: LedgerPeersConsensusInterface extraAPI m, getLocalRootHotTarget :: STM m HotValency, pcaPeerSelectionTargets:: PeerSelectionTargets, -- ^ configured peer selection targets diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs index 975be2d4bc3..82aecef082d 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs @@ -10,7 +10,7 @@ module Ouroboros.Network.PeerSelection.PeerSelectionActions ( PeerSelectionActions (..) , withPeerSelectionActions , requestPeerSharingResult - , requestPublicRootPeers + , requestPublicRootPeersImpl ) where @@ -129,7 +129,7 @@ requestPeerSharingResult sharingController amount peer = do -- are found, it retrieves extra peers instead. The result includes the -- public root peers and the time taken for the operation. -- -requestPublicRootPeers +requestPublicRootPeersImpl :: forall m peeraddr extraPeers resolver. ( MonadThrow m , MonadAsync m @@ -147,7 +147,7 @@ requestPublicRootPeers -> StdGen -> Int -> m (PublicRootPeers extraPeers peeraddr, DiffTime) -requestPublicRootPeers +requestPublicRootPeersImpl publicTracer readPublicRootPeers PeerActionsDNS { paToPeerAddr = toPeerAddr , paDnsActions = dnsActions diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs index b78789d4d8d..a753b30918c 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/State/LocalRootPeers.hs @@ -44,9 +44,9 @@ import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise) -- data LocalRootConfig extraFlags = LocalRootConfig { - peerAdvertise :: !PeerAdvertise, - diffusionMode :: !DiffusionMode, - extraFlags :: !extraFlags + peerAdvertise :: !PeerAdvertise, + diffusionMode :: !DiffusionMode, + extraLocalRootFlags :: !extraFlags } deriving (Show, Eq) diff --git a/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs b/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs index 0a489afc210..275fad7d22a 100644 --- a/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs +++ b/ouroboros-network/orphan-instances/Ouroboros/Network/OrphanInstances.hs @@ -50,7 +50,6 @@ import Ouroboros.Network.Protocol.Limits (ProtocolLimitFailure (ExceededSizeLimit, ExceededTimeLimit)) import Ouroboros.Network.Protocol.LocalTxSubmission.Type (LocalTxSubmission) import Ouroboros.Network.Protocol.LocalTxSubmission.Type qualified as LocalTxSubmission -import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingAmount (..)) import Ouroboros.Network.Protocol.PeerSharing.Type qualified as PeerSharing import Ouroboros.Network.Protocol.TxSubmission2.Type (TxSubmission2) import Ouroboros.Network.Protocol.TxSubmission2.Type qualified as Tx @@ -80,21 +79,10 @@ import Ouroboros.Network.InboundGovernor.State (RemoteSt) import Ouroboros.Network.InboundGovernor.State qualified as InboundGovernor import Ouroboros.Network.Mux (MiniProtocolNum (..)) import Ouroboros.Network.PeerSelection hiding (PublicRootPeers) -import Ouroboros.Network.PeerSelection.Governor.Types (AssociationMode (..), - DebugPeerSelectionState (..), PeerSharingResult (..), - TracePeerSelection (..)) -import Ouroboros.Network.PeerSelection.LedgerPeers (PoolStake (..)) +import Ouroboros.Network.PeerSelection.Churn import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers -import Ouroboros.Network.PeerSelection.RootPeersDNS -import Ouroboros.Network.PeerSelection.State.KnownPeers - (KnownPeerInfo (KnownPeerInfo)) import Ouroboros.Network.PeerSelection.State.KnownPeers qualified as KnownPeers -import Ouroboros.Network.PeerSelection.State.LocalRootPeers - (HotValency (HotValency), - LocalRootConfig (LocalRootConfig, peerAdvertise), LocalRootPeers, - WarmValency (WarmValency)) import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers -import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LRP import Ouroboros.Network.Server qualified as Server import Ouroboros.Network.Server.RateLimiting (AcceptConnectionsPolicyTrace (..), AcceptedConnectionsLimit (..)) @@ -154,13 +142,13 @@ localRootPeersGroupToJSON :: (extraFlags -> Maybe (Key, Value)) -- not encoded in the JSON value -> LocalRootPeersGroup extraFlags -> Value -localRootPeersGroupToJSON extraFlagsToJSON lrpg = +localRootPeersGroupToJSON extraFlagsToJSON lrpg@LocalRootPeersGroup {extraFlags} = Object $ ("accessPoints" .?= rootAccessPoints (localRoots lrpg)) <> ("advertise" .?= rootAdvertise (localRoots lrpg)) <> ("hotValency" .?= hotValency lrpg) <> ("warmValency" .?= warmValency lrpg) - <> foldMap (uncurry (.?=)) (extraFlagsToJSON (extraFlags lrpg)) + <> foldMap (uncurry (.?=)) (extraFlagsToJSON extraFlags) <> ("diffusionMode" .?= rootDiffusionMode lrpg) localRootPeersGroupsFromJSON @@ -431,11 +419,11 @@ instance ToJSON addr => ToJSON (PeerSharingResult addr) where PeerSharingNotRegisteredYet -> String "PeerSharingNotRegisteredYet" instance ToJSON extraFlags => ToJSON (LocalRootConfig extraFlags) where - toJSON LocalRootConfig { peerAdvertise, LRP.extraFlags, LRP.diffusionMode } = + toJSON LocalRootConfig { peerAdvertise, extraLocalRootFlags, LocalRootPeers.diffusionMode } = object [ "peerAdvertise" .= peerAdvertise , "diffusionMode" .= show diffusionMode - , "extraFlags" .= extraFlags + , "extraFlags" .= extraLocalRootFlags ] instance ToJSON RemoteAddress where diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs index f4489ea17d9..f1896197a3d 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/Instances.hs @@ -172,9 +172,12 @@ instance Arbitrary extraFlags => Arbitrary (LocalRootConfig extraFlags) where <$> arbitrary <*> elements [InitiatorAndResponderDiffusionMode, InitiatorOnlyDiffusionMode] <*> arbitrary - shrink a@LocalRootConfig { peerAdvertise, extraFlags, diffusionMode } = - [ a { extraFlags = peerTrustable' } - | peerTrustable' <- shrink extraFlags + shrink a@LocalRootConfig { peerAdvertise, + extraLocalRootFlags = peerTrustable, + diffusionMode + } = + [ a { extraLocalRootFlags = peerTrustable' } + | peerTrustable' <- shrink peerTrustable ] ++ [ a { peerAdvertise = peerAdvertise' } diff --git a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs index 25433b1ff86..1c1aec5929a 100644 --- a/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs +++ b/ouroboros-network/tests/lib/Test/Ouroboros/Network/PeerSelection/RootPeersDNS.hs @@ -72,9 +72,6 @@ import Control.Tracer (Tracer (Tracer), contramap, nullTracer, traceWith) import Ouroboros.Network.DiffusionMode import Ouroboros.Network.PeerSelection -import Ouroboros.Network.PeerSelection.RootPeersDNS -import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency (..), - LocalRootConfig (..), WarmValency (..)) import Test.Ouroboros.Network.Data.Script (Script (Script), initScript', scriptHead, singletonScript, stepScript') import Test.Ouroboros.Network.PeerSelection.Instances From 00af40dc44f87daa0032723b64269a53d23aee3a Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 24 Sep 2025 21:07:23 +0200 Subject: [PATCH 15/24] peer-selection: reorganised exports, part 2 Added `Cardano.Network.PeerSelection` which re-export useful cardano peer selection APIs. --- .../api/lib/Cardano/Network/FetchMode.hs | 6 ++- .../Cardano/Network/LedgerStateJudgement.hs | 14 ++++++ .../Network/PeerSelection/Bootstrap.hs | 3 +- .../api/lib/Cardano/Network/Types.hs | 29 ----------- cardano-diffusion/cardano-diffusion.cabal | 4 +- .../lib/Cardano/Network/Diffusion.hs | 7 +-- .../Network/Diffusion/Configuration.hs | 3 +- .../lib/Cardano/Network/Diffusion/Handlers.hs | 6 ++- .../lib/Cardano/Network/Diffusion/Types.hs | 48 ++++++++----------- .../Network/LedgerPeerConsensusInterface.hs | 17 +++++-- .../lib/Cardano/Network/PeerSelection.hs | 23 +++++++++ .../Cardano/Network/PeerSelection/Churn.hs | 12 +++-- .../Network/PeerSelection/Governor/Monitor.hs | 2 +- .../Governor/PeerSelectionState.hs | 26 ++++++++-- .../Network/PeerSelection/Governor/Types.hs | 7 +-- .../PeerSelection/PeerSelectionActions.hs | 8 ++-- .../Cardano/Network/OrphanInstances.hs | 10 ++-- .../Test/Cardano/Network/Diffusion/Testnet.hs | 28 ++++------- .../Network/Diffusion/Testnet/Simulation.hs | 25 ++++------ .../lib/Test/Cardano/Network/PeerSelection.hs | 28 +++-------- .../Network/PeerSelection/Instances.hs | 14 +++--- .../Network/PeerSelection/MockEnvironment.hs | 43 +++++------------ 22 files changed, 172 insertions(+), 191 deletions(-) create mode 100644 cardano-diffusion/api/lib/Cardano/Network/LedgerStateJudgement.hs delete mode 100644 cardano-diffusion/api/lib/Cardano/Network/Types.hs create mode 100644 cardano-diffusion/lib/Cardano/Network/PeerSelection.hs diff --git a/cardano-diffusion/api/lib/Cardano/Network/FetchMode.hs b/cardano-diffusion/api/lib/Cardano/Network/FetchMode.hs index 8747dbc94a1..781dd73a8e8 100644 --- a/cardano-diffusion/api/lib/Cardano/Network/FetchMode.hs +++ b/cardano-diffusion/api/lib/Cardano/Network/FetchMode.hs @@ -2,13 +2,15 @@ module Cardano.Network.FetchMode ( mkReadFetchMode + , ConsensusMode (..) + , LedgerStateJudgement (..) , module Ouroboros.Network.BlockFetch.ConsensusInterface ) where import Data.Functor ((<&>)) -import Cardano.Network.ConsensusMode (ConsensusMode (..)) -import Cardano.Network.Types (LedgerStateJudgement (..)) +import Cardano.Network.ConsensusMode +import Cardano.Network.LedgerStateJudgement import Ouroboros.Network.BlockFetch.ConsensusInterface diff --git a/cardano-diffusion/api/lib/Cardano/Network/LedgerStateJudgement.hs b/cardano-diffusion/api/lib/Cardano/Network/LedgerStateJudgement.hs new file mode 100644 index 00000000000..dba4496e1a8 --- /dev/null +++ b/cardano-diffusion/api/lib/Cardano/Network/LedgerStateJudgement.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} + +module Cardano.Network.LedgerStateJudgement (LedgerStateJudgement (..)) where + +import GHC.Generics (Generic) +import NoThunks.Class (NoThunks) + +-- | Wether the node is caught up or fell too far behind the chain +data LedgerStateJudgement = YoungEnough | TooOld + deriving (Eq, Show, Generic) + +instance NoThunks LedgerStateJudgement diff --git a/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs b/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs index c013654a954..fdaa0175f39 100644 --- a/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs +++ b/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs @@ -8,8 +8,9 @@ module Cardano.Network.PeerSelection.Bootstrap , isNodeAbleToMakeProgress ) where -import Cardano.Network.Types (LedgerStateJudgement (..)) import GHC.Generics (Generic) + +import Cardano.Network.LedgerStateJudgement import Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint) -- | `UseBootstrapPeers` is read from the topology file. It's value might diff --git a/cardano-diffusion/api/lib/Cardano/Network/Types.hs b/cardano-diffusion/api/lib/Cardano/Network/Types.hs deleted file mode 100644 index 9cbf8a2c6f6..00000000000 --- a/cardano-diffusion/api/lib/Cardano/Network/Types.hs +++ /dev/null @@ -1,29 +0,0 @@ -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} - -module Cardano.Network.Types where - -import Data.Aeson (FromJSON) -import GHC.Generics (Generic) -import NoThunks.Class (NoThunks) - --- | Wether the node is caught up or fell too far behind the chain -data LedgerStateJudgement = YoungEnough | TooOld - deriving (Eq, Show, Generic) - -instance NoThunks LedgerStateJudgement - --- | Minimum number of hot big ledger peers in Genesis mode --- for trusted state to be signalled to Consensus. This number --- should be smaller than the `targetNumberOfActiveBigLedgerPeers` --- but greater than 1. In Genesis, we may demote a big ledger peer --- for underperformance, but not promote a replacement immediately --- to guard against adversaries which may want to slow down our --- progress. --- -newtype NumberOfBigLedgerPeers = - NumberOfBigLedgerPeers { getNumberOfBigLedgerPeers :: Int } - deriving stock (Eq, Show) - deriving newtype (FromJSON) - diff --git a/cardano-diffusion/cardano-diffusion.cabal b/cardano-diffusion/cardano-diffusion.cabal index bdc606c4a09..efb4eda9b55 100644 --- a/cardano-diffusion/cardano-diffusion.cabal +++ b/cardano-diffusion/cardano-diffusion.cabal @@ -58,12 +58,12 @@ library api exposed-modules: Cardano.Network.ConsensusMode Cardano.Network.FetchMode + Cardano.Network.LedgerStateJudgement Cardano.Network.NodeToClient.Version Cardano.Network.NodeToNode.Version Cardano.Network.PeerSelection.Bootstrap Cardano.Network.PeerSelection.LocalRootPeers Cardano.Network.PeerSelection.PeerTrustable - Cardano.Network.Types build-depends: aeson, @@ -110,6 +110,7 @@ library Cardano.Network.LedgerPeerConsensusInterface Cardano.Network.NodeToClient Cardano.Network.NodeToNode + Cardano.Network.PeerSelection Cardano.Network.PeerSelection.Churn Cardano.Network.PeerSelection.ExtraRootPeers Cardano.Network.PeerSelection.Governor.Monitor @@ -147,6 +148,7 @@ library TypeInType build-depends: + aeson, base >=4.14 && <4.22, bytestring, cardano-diffusion:{api, protocols}, diff --git a/cardano-diffusion/lib/Cardano/Network/Diffusion.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion.hs index e9529c03cd9..94e1c4c1d48 100644 --- a/cardano-diffusion/lib/Cardano/Network/Diffusion.hs +++ b/cardano-diffusion/lib/Cardano/Network/Diffusion.hs @@ -30,17 +30,14 @@ import Cardano.Network.NodeToClient qualified as NodeToClient import Cardano.Network.NodeToNode (NodeToNodeVersionData (..), RemoteAddress, ntnDataFlow) import Cardano.Network.NodeToNode qualified as NodeToNode +import Cardano.Network.PeerSelection qualified as Cardano import Cardano.Network.PeerSelection.Churn qualified as Cardano.Churn import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano -import Cardano.Network.PeerSelection.Governor.PeerSelectionActions qualified as Cardano import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano.PeerSelectionState import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano.Types -import Cardano.Network.PeerSelection.PeerSelectionActions qualified as Cardano import Ouroboros.Network.Diffusion qualified as Diffusion import Ouroboros.Network.IOManager -import Ouroboros.Network.PeerSelection.LedgerPeers.Type - (LedgerPeersConsensusInterface (..)) import Ouroboros.Network.PeerSelection.PeerStateActions import Ouroboros.Network.Protocol.Handshake @@ -150,7 +147,7 @@ run CardanoNodeArguments { daPeerSelectionStateToExtraCounters = Cardano.Types.cardanoPeerSelectionStatetoCounters, daToExtraPeers = flip Cardano.ExtraPeers Set.empty, daRequestPublicRootPeers = - Just $ Cardano.requestPublicRootPeers + Just $ Cardano.requestPublicRootPeersImpl (Diffusion.dtTracePublicRootPeersTracer tracers) readUseBootstrapPeers (Cardano.getLedgerStateJudgement (lpExtraAPI ledgerPeersAPI)) diff --git a/cardano-diffusion/lib/Cardano/Network/Diffusion/Configuration.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion/Configuration.hs index 8727a6d541d..e25e49ab5ee 100644 --- a/cardano-diffusion/lib/Cardano/Network/Diffusion/Configuration.hs +++ b/cardano-diffusion/lib/Cardano/Network/Diffusion/Configuration.hs @@ -24,7 +24,8 @@ module Cardano.Network.Diffusion.Configuration import Cardano.Network.NodeToNode (MiniProtocolParameters (..), defaultMiniProtocolParameters) -import Cardano.Network.Types (NumberOfBigLedgerPeers (..)) +import Cardano.Network.PeerSelection.Governor.PeerSelectionState + (NumberOfBigLedgerPeers (..)) import Ouroboros.Network.BlockFetch (BlockFetchConfiguration (..), GenesisBlockFetchConfiguration (..)) diff --git a/cardano-diffusion/lib/Cardano/Network/Diffusion/Handlers.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion/Handlers.hs index 47f035f520c..799f5202fc0 100644 --- a/cardano-diffusion/lib/Cardano/Network/Diffusion/Handlers.hs +++ b/cardano-diffusion/lib/Cardano/Network/Diffusion/Handlers.hs @@ -8,19 +8,21 @@ module Cardano.Network.Diffusion.Handlers where +import Control.Concurrent.Class.MonadSTM.Strict import Control.Monad.Class.MonadTime.SI +import Cardano.Network.LedgerStateJudgement import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers) import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano -import Cardano.Network.Types (LedgerStateJudgement) -import Control.Concurrent.Class.MonadSTM.Strict + import Ouroboros.Network.ConnectionManager.Types import Ouroboros.Network.Diffusion.Types (Tracers (..)) import Ouroboros.Network.PeerSelection.Governor import Ouroboros.Network.PeerSelection.LedgerPeers.Type (UseLedgerPeers) import Ouroboros.Network.PeerSelection.PeerMetric import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing) + #ifdef POSIX import Control.Tracer (traceWith) import Ouroboros.Network.ConnectionManager.Core (Trace (..)) diff --git a/cardano-diffusion/lib/Cardano/Network/Diffusion/Types.hs b/cardano-diffusion/lib/Cardano/Network/Diffusion/Types.hs index 2f972df7b6f..8b0de68fbd2 100644 --- a/cardano-diffusion/lib/Cardano/Network/Diffusion/Types.hs +++ b/cardano-diffusion/lib/Cardano/Network/Diffusion/Types.hs @@ -18,8 +18,8 @@ module Cardano.Network.Diffusion.Types , CardanoTracePeerSelection , CardanoDebugPeerSelection -- * Re-exports - , PeerMetrics , Cardano.Churn.TraceChurnMode (..) + , module Reexports ) where @@ -27,31 +27,21 @@ import Control.Concurrent.Class.MonadSTM.Strict import Control.Tracer (Tracer) import Network.Socket (SockAddr, Socket) -import Cardano.Network.ConsensusMode +import Cardano.Network.ConsensusMode as Reexports (ConsensusMode (..)) import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano import Cardano.Network.NodeToClient (LocalAddress, LocalSocket, NodeToClientVersion, NodeToClientVersionData) import Cardano.Network.NodeToNode (NodeToNodeVersion, NodeToNodeVersionData, RemoteAddress) -import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers) +import Cardano.Network.PeerSelection as Rexports (NumberOfBigLedgerPeers (..), + PeerTrustable (..), UseBootstrapPeers (..)) +import Cardano.Network.PeerSelection qualified as Cardano import Cardano.Network.PeerSelection.Churn qualified as Cardano.Churn -import Cardano.Network.PeerSelection.ExtraRootPeers (ExtraPeers) -import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano -import Cardano.Network.PeerSelection.Governor.PeerSelectionState (ExtraState) -import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano -import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano -import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) -import Cardano.Network.Types (NumberOfBigLedgerPeers (..)) import Ouroboros.Network.Diffusion qualified as Diffusion -import Ouroboros.Network.PeerSelection.Governor.Types (DebugPeerSelection, - PeerSelectionCounters, PeerSelectionTargets (..), TracePeerSelection) -import Ouroboros.Network.PeerSelection.LedgerPeers.Type - (LedgerPeersConsensusInterface (..)) -import Ouroboros.Network.PeerSelection.PeerMetric (PeerMetrics) -import Ouroboros.Network.PeerSelection.RootPeersDNS.LocalRootPeers - (TraceLocalRootPeers) -import Ouroboros.Network.PeerSelection.State.LocalRootPeers (LocalRootConfig) +import Ouroboros.Network.PeerSelection as Reexports + (LedgerPeersConsensusInterface (..), PeerMetrics, + PeerSelectionTargets) -- | Arguments required to instantiate Cardano Node Diffusion -- @@ -133,26 +123,26 @@ type CardanoApplications m a = -type CardanoLocalRootConfig = LocalRootConfig PeerTrustable +type CardanoLocalRootConfig = Cardano.LocalRootConfig PeerTrustable type CardanoTraceLocalRootPeers = - TraceLocalRootPeers PeerTrustable RemoteAddress + Cardano.TraceLocalRootPeers PeerTrustable RemoteAddress type CardanoTracePeerSelection = - TracePeerSelection Cardano.DebugPeerSelectionState - PeerTrustable - (ExtraPeers SockAddr) - RemoteAddress + Cardano.TracePeerSelection Cardano.DebugPeerSelectionState + PeerTrustable + (Cardano.ExtraPeers SockAddr) + RemoteAddress type CardanoDebugPeerSelection = - DebugPeerSelection ExtraState - PeerTrustable - (ExtraPeers RemoteAddress) - RemoteAddress + Cardano.DebugPeerSelection Cardano.ExtraState + PeerTrustable + (Cardano.ExtraPeers RemoteAddress) + RemoteAddress type CardanoPeerSelectionCounters = - PeerSelectionCounters (Cardano.ExtraPeerSelectionSetsWithSizes RemoteAddress) + Cardano.PeerSelectionCounters (Cardano.ExtraPeerSelectionSetsWithSizes RemoteAddress) diff --git a/cardano-diffusion/lib/Cardano/Network/LedgerPeerConsensusInterface.hs b/cardano-diffusion/lib/Cardano/Network/LedgerPeerConsensusInterface.hs index 1b1789e8c90..615cb5a3edb 100644 --- a/cardano-diffusion/lib/Cardano/Network/LedgerPeerConsensusInterface.hs +++ b/cardano-diffusion/lib/Cardano/Network/LedgerPeerConsensusInterface.hs @@ -1,9 +1,18 @@ -module Cardano.Network.LedgerPeerConsensusInterface where +module Cardano.Network.LedgerPeerConsensusInterface + ( LedgerPeersConsensusInterface (..) + -- * Re-exports + , FetchMode (..) + , LedgerStateJudgement (..) + , OutboundConnectionsState (..) + ) where -import Cardano.Network.PeerSelection.LocalRootPeers (OutboundConnectionsState) -import Cardano.Network.Types (LedgerStateJudgement) import Control.Concurrent.Class.MonadSTM (MonadSTM (..)) -import Ouroboros.Network.BlockFetch.ConsensusInterface (FetchMode) + +import Ouroboros.Network.BlockFetch.ConsensusInterface (FetchMode (..)) + +import Cardano.Network.LedgerStateJudgement +import Cardano.Network.PeerSelection.LocalRootPeers + (OutboundConnectionsState (..)) -- | Cardano Node specific consensus interface actions. -- diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection.hs new file mode 100644 index 00000000000..9e471e593ce --- /dev/null +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection.hs @@ -0,0 +1,23 @@ +module Cardano.Network.PeerSelection + ( module Cardano.PeerSelection + , module Ouroboros.PeerSelection + ) where + +import Cardano.Network.PeerSelection.Bootstrap as Cardano.PeerSelection +import Cardano.Network.PeerSelection.Churn as Cardano.PeerSelection + (ChurnMode (..), ExtraArguments, TraceChurnMode (..), + peerChurnGovernor) +import Cardano.Network.PeerSelection.ExtraRootPeers as Cardano.PeerSelection + (ExtraPeers (..)) +import Cardano.Network.PeerSelection.Governor.PeerSelectionActions as Cardano.PeerSelection +import Cardano.Network.PeerSelection.Governor.PeerSelectionState as Cardano.PeerSelection + (DebugPeerSelectionState (..), ExtraState) +import Cardano.Network.PeerSelection.Governor.Types as Cardano.PeerSelection +import Cardano.Network.PeerSelection.LocalRootPeers as Cardano.PeerSelection +import Cardano.Network.PeerSelection.PeerSelectionActions as Cardano.PeerSelection +import Cardano.Network.PeerSelection.PeerTrustable as Cardano.PeerSelection +import Cardano.Network.PeerSelection.PublicRootPeers as Cardano.PeerSelection + (CardanoPublicRootPeers) + +import Ouroboros.Network.PeerSelection as Ouroboros.PeerSelection hiding + (DebugPeerSelectionState (..), LedgerPeersConsensusInterface) diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs index 8cda2a0d819..b225eb2de5a 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs @@ -13,7 +13,8 @@ -- | This subsystem manages the discovery and selection of /upstream/ peers. -- module Cardano.Network.PeerSelection.Churn - ( ChurnMode (..) + ( PeerChurnArgs (..) + , ChurnMode (..) , TraceChurnMode (..) , ExtraArguments (..) , peerChurnGovernor @@ -21,21 +22,22 @@ module Cardano.Network.PeerSelection.Churn import Data.Void (Void) +import Control.Applicative (Alternative) import Control.Concurrent.Class.MonadSTM.Strict import Control.Monad.Class.MonadThrow import Control.Monad.Class.MonadTime.SI import Control.Monad.Class.MonadTimer.SI import Control.Tracer (Tracer, traceWith) +import Data.Functor (($>)) +import Data.Monoid.Synchronisation (FirstToFinish (..)) import System.Random import Cardano.Network.ConsensusMode (ConsensusMode (..)) import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano +import Cardano.Network.LedgerStateJudgement import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano -import Cardano.Network.Types (LedgerStateJudgement (..)) -import Control.Applicative (Alternative) -import Data.Functor (($>)) -import Data.Monoid.Synchronisation (FirstToFinish (..)) + import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..)) import Ouroboros.Network.Diffusion.Policies (churnEstablishConnectionTimeout, closeConnectionTimeout, deactivateTimeout) diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs index 138ce6cd744..18a44512f7f 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Monitor.hs @@ -27,6 +27,7 @@ import Control.Monad.Class.MonadTimer.SI import Cardano.Network.ConsensusMode import Cardano.Network.Diffusion.Configuration qualified as Cardano (srvPrefix) import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano +import Cardano.Network.LedgerStateJudgement import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), isBootstrapPeersEnabled, isNodeAbleToMakeProgress, requiresBootstrapPeers) @@ -36,7 +37,6 @@ import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Ca import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers -import Cardano.Network.Types (LedgerStateJudgement (..)) import Control.Exception (assert) import Data.Map.Strict (Map) import Data.Map.Strict qualified as Map diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs index b2868aadd63..07636bd8fc4 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/PeerSelectionState.hs @@ -1,10 +1,30 @@ +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} + module Cardano.Network.PeerSelection.Governor.PeerSelectionState where +import Control.Monad.Class.MonadTime.SI (Time (..)) +import Data.Aeson (FromJSON) + import Cardano.Network.ConsensusMode (ConsensusMode) +import Cardano.Network.LedgerStateJudgement import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) -import Cardano.Network.Types (LedgerStateJudgement (..), - NumberOfBigLedgerPeers (..)) -import Control.Monad.Class.MonadTime.SI (Time (..)) + + +-- | Minimum number of hot big ledger peers in Genesis mode +-- for trusted state to be signalled to Consensus. This number +-- should be smaller than the `targetNumberOfActiveBigLedgerPeers` +-- but greater than 1. In Genesis, we may demote a big ledger peer +-- for underperformance, but not promote a replacement immediately +-- to guard against adversaries which may want to slow down our +-- progress. +-- +newtype NumberOfBigLedgerPeers = + NumberOfBigLedgerPeers { getNumberOfBigLedgerPeers :: Int } + deriving stock (Eq, Show) + deriving newtype (FromJSON) + + -- | Cardano Node PeerSelection State extension data type. -- It contain specific PeerSelection state parameters to guide the Outbound diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Types.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Types.hs index 1a896ac318b..ce3f9735285 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Types.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Governor/Types.hs @@ -9,10 +9,12 @@ module Cardano.Network.PeerSelection.Governor.Types , cardanoPeerSelectionGovernorArgs , readAssociationMode , Cardano.ExtraTrace (..) + , Cardano.NumberOfBigLedgerPeers (..) ) where import Cardano.Network.ConsensusMode (ConsensusMode (..)) import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano +import Cardano.Network.LedgerStateJudgement import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), requiresBootstrapPeers) import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano @@ -27,8 +29,6 @@ import Cardano.Network.PeerSelection.LocalRootPeers import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers -import Cardano.Network.Types (LedgerStateJudgement (..), - getNumberOfBigLedgerPeers) import Control.Applicative (Alternative) import Control.Concurrent.Class.MonadSTM import Control.Monad.Class.MonadTimer.SI @@ -45,6 +45,7 @@ import Ouroboros.Network.PeerSelection.LedgerPeers import Ouroboros.Network.PeerSelection.PublicRootPeers (getBigLedgerPeers) import Ouroboros.Network.PeerSelection.State.EstablishedPeers qualified as EstablishedPeers + -- | Peer selection view. -- -- This is a functor which is used to hold computation of various peer sets and @@ -182,7 +183,7 @@ outboundConnectionsState -- Genesis mode (Unrestricted, DontUseBootstrapPeers, GenesisMode) - | activeNumBigLedgerPeers >= getNumberOfBigLedgerPeers minNumberOfBigLedgerPeers + | activeNumBigLedgerPeers >= Cardano.getNumberOfBigLedgerPeers minNumberOfBigLedgerPeers -> TrustedStateWithExternalPeers | otherwise diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs index 50e8dfc8f49..457a0cde39b 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/PeerSelectionActions.hs @@ -6,11 +6,11 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} -module Cardano.Network.PeerSelection.PeerSelectionActions (requestPublicRootPeers) where +module Cardano.Network.PeerSelection.PeerSelectionActions (requestPublicRootPeersImpl) where +import Cardano.Network.LedgerStateJudgement (LedgerStateJudgement) import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), requiresBootstrapPeers) -import Cardano.Network.Types (LedgerStateJudgement) import Control.Concurrent.Class.MonadSTM.Strict import Control.Monad.Class.MonadAsync (MonadAsync) @@ -39,7 +39,7 @@ import System.Random -- We start by reading the current ledger state judgement, if it is -- YoungEnough we only care about fetching for ledger peers, otherwise we -- aim to fetch bootstrap peers. -requestPublicRootPeers +requestPublicRootPeersImpl :: forall m peeraddr resolver. ( MonadThrow m , MonadAsync m @@ -58,7 +58,7 @@ requestPublicRootPeers -> StdGen -> Int -> m (CardanoPublicRootPeers peeraddr, DiffTime) -requestPublicRootPeers +requestPublicRootPeersImpl publicTracer useBootstrapped getLedgerStateJudgement readPublicRootPeers pad@PeerActionsDNS { paToPeerAddr = toPeerAddr diff --git a/cardano-diffusion/orphan-instances/Cardano/Network/OrphanInstances.hs b/cardano-diffusion/orphan-instances/Cardano/Network/OrphanInstances.hs index 2e32b7482e8..944a8d88f32 100644 --- a/cardano-diffusion/orphan-instances/Cardano/Network/OrphanInstances.hs +++ b/cardano-diffusion/orphan-instances/Cardano/Network/OrphanInstances.hs @@ -11,16 +11,14 @@ import Data.Aeson import Data.Aeson qualified as Aeson import Data.Map qualified as Map +import Cardano.Network.LedgerStateJudgement import Cardano.Network.NodeToClient (NodeToClientVersion (..), NodeToClientVersionData (..)) import Cardano.Network.NodeToNode (NodeToNodeVersion (..), NodeToNodeVersionData (..)) -import Cardano.Network.PeerSelection.Bootstrap -import Cardano.Network.PeerSelection.Governor.Types (ExtraTrace (..)) -import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) -import Cardano.Network.PeerSelection.PublicRootPeers (CardanoPublicRootPeers, - getBootstrapPeers, getPublicConfigPeers) -import Cardano.Network.Types +import Cardano.Network.PeerSelection +import Cardano.Network.PeerSelection.PublicRootPeers (getBootstrapPeers, + getPublicConfigPeers) import Ouroboros.Network.Diffusion.Topology import Ouroboros.Network.Magic (NetworkMagic (..)) diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs index 5101a7809d2..e1eb129dbee 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs @@ -51,18 +51,15 @@ import Network.DNS.Types qualified as DNS import Network.Mux.Trace qualified as Mx import Cardano.Network.ConsensusMode +import Cardano.Network.LedgerStateJudgement import Cardano.Network.NodeToNode (DiffusionMode (..)) -import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), - requiresBootstrapPeers) -import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano +import Cardano.Network.PeerSelection (NumberOfBigLedgerPeers (..), + PeerTrustable (..), UseBootstrapPeers (..)) +import Cardano.Network.PeerSelection qualified as Cardano import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano.ExtraPeers -import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano.ExtraState -import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano -import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) import Cardano.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers -import Cardano.Network.Types (LedgerStateJudgement, NumberOfBigLedgerPeers (..)) import Ouroboros.Network.Block (BlockNo (..)) import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..), @@ -77,16 +74,12 @@ import Ouroboros.Network.ExitPolicy (RepromoteDelay (..)) import Ouroboros.Network.InboundGovernor qualified as IG import Ouroboros.Network.Mock.ConcreteBlock (BlockHeader) import Ouroboros.Network.PeerSelection -import Ouroboros.Network.PeerSelection.Governor hiding (PeerSelectionState (..)) import Ouroboros.Network.PeerSelection.Governor qualified as Governor import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers -import Ouroboros.Network.PeerSelection.RootPeersDNS hiding (IOError) +import Ouroboros.Network.PeerSelection.RootPeersDNS (DNSorIOError (DNSError)) import Ouroboros.Network.PeerSelection.State.EstablishedPeers qualified as EstablishedPeers import Ouroboros.Network.PeerSelection.State.KnownPeers qualified as KnownPeers -import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency (..), - LocalRootConfig (..), WarmValency (..)) import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers -import Ouroboros.Network.PeerSharing (PeerSharingResult (..)) import Ouroboros.Network.Server qualified as Server import Ouroboros.Network.TxSubmission.Inbound.V2.Policy import Ouroboros.Network.TxSubmission.Inbound.V2.Types @@ -110,7 +103,6 @@ import Test.Ouroboros.Network.TxSubmission.TxLogic (ArbTxDecisionPolicy (..)) import Test.Ouroboros.Network.TxSubmission.Types (Tx (..), TxId) import Test.Ouroboros.Network.Utils hiding (SmallDelay, debugTracer) - import Test.QuickCheck import Test.Tasty import Test.Tasty.QuickCheck (testProperty) @@ -525,7 +517,7 @@ prop_diffusion_nofail ioSimTrace traceNumber = in ioProperty $ do r <- evaluate ( List.foldl' (flip seq) True - $ [ assertPeerSelectionState Cardano.toSet Cardano.invariant st () + $ [ assertPeerSelectionState Cardano.ExtraPeers.toSet Cardano.ExtraPeers.invariant st () | (_, DiffusionDebugPeerSelectionTrace (TraceGovernorState _ _ st)) <- trace ] ) `catch` \(AssertionFailed _) -> return False @@ -1197,7 +1189,7 @@ prop_only_bootstrap_peers_in_fallback_state ioSimTrace traceNumber = let govUseBootstrapPeers :: Signal UseBootstrapPeers govUseBootstrapPeers = selectDiffusionPeerSelectionState - (Cardano.bootstrapPeersFlag . Governor.extraState) + (Cardano.ExtraState.bootstrapPeersFlag . Governor.extraState) events -- A signal which shows when bootstrap peers changed and are no @@ -1220,7 +1212,7 @@ prop_only_bootstrap_peers_in_fallback_state ioSimTrace traceNumber = govLedgerStateJudgement :: Signal LedgerStateJudgement govLedgerStateJudgement = selectDiffusionPeerSelectionState - (Cardano.ledgerStateJudgement . Governor.extraState) + (Cardano.ExtraState.ledgerStateJudgement . Governor.extraState) events trJoinKillSig :: Signal JoinedOrKilled @@ -1277,7 +1269,7 @@ prop_only_bootstrap_peers_in_fallback_state ioSimTrace traceNumber = ) -> if isAlive && not useBootstrapPeersChanged - && requiresBootstrapPeers useBootstrapPeers ledgerStateJudgement + && Cardano.requiresBootstrapPeers useBootstrapPeers ledgerStateJudgement then knownPeers `Set.difference` trustedPeers else Set.empty ) @@ -5121,7 +5113,7 @@ selectDiffusionPeerSelectionState f = . Signal.selectEvents (\case DiffusionDebugPeerSelectionTrace (TraceGovernorState _ _ st) -> - Just (Cardano.consensusMode (Governor.extraState st), f st) + Just (Cardano.ExtraState.consensusMode (Governor.extraState st), f st) _ -> Nothing) where diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs index 7d27f462176..2f3b4888247 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet/Simulation.hs @@ -78,16 +78,9 @@ import Network.TypedProtocol.PingPong.Type qualified as PingPong import Cardano.Network.ConsensusMode import Cardano.Network.Diffusion.Configuration qualified as Cardano -import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) -import Cardano.Network.PeerSelection.LocalRootPeers - (OutboundConnectionsState (..)) -import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) -import Cardano.Network.Types (LedgerStateJudgement (..), - NumberOfBigLedgerPeers (..)) - import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano -import Cardano.Network.PeerSelection.Churn (ChurnMode (..), TraceChurnMode, - peerChurnGovernor) +import Cardano.Network.LedgerStateJudgement +import Cardano.Network.PeerSelection hiding (requestPublicRootPeers) import Cardano.Network.PeerSelection.Churn qualified as Churn import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano import Cardano.Network.PeerSelection.Governor.PeerSelectionActions qualified as Cardano @@ -96,8 +89,6 @@ import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Ca import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as ExtraState import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano import Cardano.Network.PeerSelection.Governor.Types qualified as ExtraSizes -import Cardano.Network.PeerSelection.PeerSelectionActions - (requestPublicRootPeers) import Ouroboros.Network.Block (BlockNo) import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..), @@ -115,8 +106,8 @@ import Ouroboros.Network.Handshake.Acceptable (Acceptable (acceptableVersion)) import Ouroboros.Network.InboundGovernor (RemoteTransitionTrace) import Ouroboros.Network.InboundGovernor qualified as IG import Ouroboros.Network.Mux (MiniProtocolLimits (..)) -import Ouroboros.Network.PeerSelection hiding (requestPublicRootPeers) -import Ouroboros.Network.PeerSelection.Governor qualified as Governor +import Ouroboros.Network.PeerSelection +import Ouroboros.Network.PeerSelection qualified as Governor import Ouroboros.Network.PeerSelection.LedgerPeers (accPoolStake) import Ouroboros.Network.Protocol.BlockFetch.Codec (byteLimitsBlockFetch, timeLimitsBlockFetch) @@ -1320,10 +1311,10 @@ diffusionSimulation tracers = mkTracers addr i requestPublicRootPeers' = - requestPublicRootPeers (Diffusion.dtTracePublicRootPeersTracer tracers) - readUseBootstrapPeers - (pure TooOld) - readPublicRootPeers + requestPublicRootPeersImpl (Diffusion.dtTracePublicRootPeersTracer tracers) + readUseBootstrapPeers + (pure TooOld) + readPublicRootPeers tracerTxLogic = diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs index 72e0f7d17ba..646a4713039 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection.hs @@ -56,32 +56,19 @@ import Network.DNS qualified as DNS (defaultResolvConf) import Network.Socket (SockAddr) import Cardano.Network.ConsensusMode -import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), - requiresBootstrapPeers) -import Cardano.Network.PeerSelection.LocalRootPeers (OutboundConnectionsState) -import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) +import Cardano.Network.PeerSelection import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy (RepromoteDelay (..)) -import Ouroboros.Network.PeerSelection.Governor hiding (PeerSelectionState (..), - peerSharing) +import Ouroboros.Network.PeerSelection import Ouroboros.Network.PeerSelection.Governor qualified as Governor -import Ouroboros.Network.PeerSelection.LedgerPeers -import Ouroboros.Network.PeerSelection.PeerAdvertise -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) -import Ouroboros.Network.PeerSelection.PublicRootPeers (PublicRootPeers) import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers -import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSActions -import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSSemaphore -import Ouroboros.Network.PeerSelection.RootPeersDNS.PublicRootPeers import Ouroboros.Network.PeerSelection.State.EstablishedPeers qualified as EstablishedPeers import Ouroboros.Network.PeerSelection.State.KnownPeers qualified as KnownPeers -import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency (..), - LocalRootConfig (..), LocalRootPeers (..), WarmValency (..)) -import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers +import Ouroboros.Network.PeerSelection.State.LocalRootPeers + (LocalRootPeers (..)) import Ouroboros.Network.Point -import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingResult (..)) import Test.Cardano.Network.PeerSelection.MockEnvironment hiding (tests) import Test.Cardano.Network.PeerSelection.Utils @@ -97,16 +84,13 @@ import Test.Ouroboros.Network.Utils (disjointSetsProperty, isSubsetProperty, import Control.Monad.IOSim import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano -import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano +import Cardano.Network.LedgerStateJudgement +import Cardano.Network.PeerSelection qualified as Cardano import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano.ExtraPeers -import Cardano.Network.PeerSelection.Governor.PeerSelectionActions qualified as Cardano import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano.ExtraState -import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano.ExtraSizes import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers -import Cardano.Network.Types (LedgerStateJudgement (..), - NumberOfBigLedgerPeers (..)) import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..)) import Test.QuickCheck import Test.Tasty diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Instances.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Instances.hs index 7e347836c84..bc664c91b84 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Instances.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/Instances.hs @@ -1,18 +1,16 @@ -{-# LANGUAGE DerivingVia #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE DerivingVia #-} {-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Network.PeerSelection.Instances (ArbitraryLedgerStateJudgement (..)) where import Cardano.Network.ConsensusMode (ConsensusMode (..)) -import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) -import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) -import Cardano.Network.Types (LedgerStateJudgement (..)) +import Cardano.Network.LedgerStateJudgement +import Cardano.Network.PeerSelection (PeerTrustable (..), + UseBootstrapPeers (..)) + import Test.Ouroboros.Network.PeerSelection.Instances () + import Test.QuickCheck diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs index 370e7b2dc5f..e6a8c18a8ff 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs @@ -28,7 +28,6 @@ module Test.Cardano.Network.PeerSelection.MockEnvironment , selectPeerSelectionTraceEventsUntil , peerShareReachablePeers , module Test.Ouroboros.Network.Data.Script - , module Ouroboros.Network.PeerSelection.Types , tests , prop_shrink_nonequal_GovernorMockEnvironment , config_REPROMOTE_DELAY @@ -64,16 +63,26 @@ import Control.Monad.Fail qualified as Fail import Control.Monad.IOSim import Control.Tracer (Tracer (..), contramap, traceWith) -import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano -import Cardano.Network.PeerSelection.Governor.Types (ExtraTrace (..), - readAssociationMode) +import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..)) import Ouroboros.Network.DiffusionMode import Ouroboros.Network.ExitPolicy +import Ouroboros.Network.PeerSelection hiding (requestPublicRootPeers) import Ouroboros.Network.PeerSelection.Governor hiding (PeerSelectionState (..)) import Ouroboros.Network.PeerSelection.Governor qualified as Governor +import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers import Ouroboros.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers import Ouroboros.Network.Point +import Cardano.Network.ConsensusMode +import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano +import Cardano.Network.LedgerStateJudgement +import Cardano.Network.PeerSelection as Cardano +import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano.ExtraPeers +import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano +import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano.ExtraState +import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano.ExtraSizes +import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers + import Test.Ouroboros.Network.Data.Script (PickScript, Script (..), ScriptDelay (..), TimedScript, arbitraryPickScript, arbitraryScriptOf, initScript, initScript', interpretPickScript, @@ -90,32 +99,6 @@ import Test.Ouroboros.Network.Utils (ShrinkCarefully, arbitrarySubset, import Test.Cardano.Network.PeerSelection.Instances import Test.Cardano.Network.PeerSelection.PublicRootPeers () -import Cardano.Network.ConsensusMode -import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano -import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..), - requiresBootstrapPeers) -import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano -import Cardano.Network.PeerSelection.ExtraRootPeers qualified as Cardano.ExtraPeers -import Cardano.Network.PeerSelection.Governor.PeerSelectionActions qualified as Cardano -import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Cardano.ExtraState -import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano -import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano.ExtraSizes -import Cardano.Network.PeerSelection.LocalRootPeers - (OutboundConnectionsState (..)) -import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) -import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers -import Cardano.Network.Types (LedgerStateJudgement (..), - NumberOfBigLedgerPeers (..)) - -import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..)) -import Ouroboros.Network.PeerSelection.LedgerPeers -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) -import Ouroboros.Network.PeerSelection.PublicRootPeers (PublicRootPeers (..)) -import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers -import Ouroboros.Network.PeerSelection.Types (PeerStatus (..)) -import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingAmount, - PeerSharingResult (..)) - import Test.QuickCheck import Test.Tasty (TestTree, localOption, testGroup) import Test.Tasty.QuickCheck (QuickCheckMaxSize (..), testProperty) From 2b6ffcc6b98d05709c0f72797f648104f68a65dc Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 24 Sep 2025 09:40:01 +0200 Subject: [PATCH 16/24] cardano-diffusion: code style improvements --- .../Test/Cardano/Network/Diffusion/Testnet.hs | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs index e1eb129dbee..440a9802ae2 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs @@ -817,18 +817,18 @@ prop_no_txSubmission_error ioSimTrace traceNumber = . Trace.take traceNumber $ ioSimTrace - in counterexample (intercalate "\n" $ map show $ events) + in counterexample (intercalate "\n" $ map show events) $ all (\case (_, DiffusionInboundGovernorTrace (IG.TrMuxErrored _ err)) -> case fromException err of - Just ProtocolErrorRequestBlocking -> False - Just ProtocolErrorRequestedNothing -> False - Just ProtocolErrorAckedTooManyTxids -> False - Just (ProtocolErrorRequestedTooManyTxids _ _ _) -> False - Just ProtocolErrorRequestNonBlocking -> False - Just ProtocolErrorRequestedUnavailableTx -> False - _ -> True - _ -> True + Just ProtocolErrorRequestBlocking -> False + Just ProtocolErrorRequestedNothing -> False + Just ProtocolErrorAckedTooManyTxids -> False + Just ProtocolErrorRequestedTooManyTxids {} -> False + Just ProtocolErrorRequestNonBlocking -> False + Just ProtocolErrorRequestedUnavailableTx -> False + _ -> True + _ -> True ) events @@ -953,10 +953,10 @@ prop_txSubmission_allTransactions (ArbTxDecisionPolicy decisionPolicy) -- things. -- -- TODO: the generator ought to give us unique `TxId`s. - uniqueTxsA = map (\(t, i) -> t { getTxId = List.foldl' (+) 0 (map ord "0.0.0.0") + i }) - (zip txsA [0 :: TxId ..]) - uniqueTxsB = map (\(t, i) -> t { getTxId = List.foldl' (+) 0 (map ord "0.0.0.1") + i }) - (zip txsB [100 :: TxId ..]) + uniqueTxsA = zipWith (\t i -> t { getTxId = List.foldl' (+) 0 (map ord "0.0.0.0") + i }) + txsA [0 :: TxId ..] + uniqueTxsB = zipWith (\t i -> t { getTxId = List.foldl' (+) 0 (map ord "0.0.0.1") + i }) + txsB [100 :: TxId ..] -- This checks the property that after running the simulation for a while -- both nodes manage to get all valid transactions. @@ -1047,18 +1047,17 @@ prop_check_inflight_ratio bi ds@(DiffusionScript simArgs _ _) = events :: Events DiffusionTestTrace events = Signal.eventsFromList . Trace.toList - . fmap ( (\(WithTime t (WithName _ b)) -> (t, b)) - ) + . fmap (\(WithTime t (WithName _ b)) -> (t, b)) . withTimeNameTraceEvents @DiffusionTestTrace @NtNAddr - . Trace.take 500000 + . Trace.take 500_000 $ runSimTrace - $ sim + sim inflightTxsMap = foldr' - (\(_, m) r -> Map.unionWith (max) m r + (\(_, m) r -> Map.unionWith max m r ) Map.empty $ Signal.eventsToList @@ -1067,7 +1066,7 @@ prop_check_inflight_ratio bi ds@(DiffusionScript simArgs _ _) = DiffusionTxLogic (TraceSharedTxState _ d) -> Just (inflightTxs d) _ -> Nothing ) - $ events + events txDecisionPolicy = saTxDecisionPolicy simArgs @@ -1076,7 +1075,7 @@ prop_check_inflight_ratio bi ds@(DiffusionScript simArgs _ _) = ++ show @(Ratio Int) (fromIntegral m / fromIntegral (txInflightMultiplicity txDecisionPolicy)) ) (Map.elems inflightTxsMap)) - $ True + True -- | This test coverage of InboundGovernor transitions. -- @@ -2028,7 +2027,7 @@ unit_4191 = testWithIOSim prop_diffusion_dns_can_recover long_trace absInfo scri , [ JoinNetwork 6.710_144_927_536 , Kill 7.454_545_454_545 , JoinNetwork 10.763_157_894_736 - , Reconfigure 0.415_384_615_384 [(1,1,Map.fromList []) + , Reconfigure 0.415_384_615_384 [(1,1,Map.empty) , (1,1,Map.empty)] , Reconfigure 15.550_561_797_752 [(1,1,Map.empty) , (1,1,Map.fromList [(RelayAccessDomain "test2" 15,LocalRootConfig DoAdvertisePeer InitiatorAndResponderDiffusionMode IsNotTrustable)])] @@ -3856,7 +3855,7 @@ prop_unit_4258 = (SimArgs 1 10 defaultTxDecisionPolicy) (singletonTimedScript Map.empty) [( NodeArgs (-3) InitiatorAndResponderDiffusionMode - (Map.fromList []) + Map.empty PraosMode (Script (UseBootstrapPeers [RelayAccessDomain "bootstrap" 0] :| [])) (TestAddress (IPAddr (read "0.0.0.4") 9)) @@ -4334,33 +4333,35 @@ unit_peer_sharing = . map (\as -> case as of [] -> -- this should be a test failure! error "invariant violation: no traces for one of the nodes" - WithName { wnName } : _ -> (wnName, mapMaybe (\a -> case a of + WithName { wnName } : _ -> ( wnName + , mapMaybe (\a -> case wtEvent (wnEvent a) of DiffusionPeerSelectionTrace b -> Just b _ -> Nothing) - . map (wtEvent . wnEvent) - $ as)) + as + ) + ) $ events' events' = Trace.toList - . splitWithNameTrace - . fmap (\(WithTime t (WithName name b)) - -> WithName name (WithTime t b)) - . withTimeNameTraceEvents - @DiffusionTestTrace - @NtNAddr - -- We need roughly 1200 because: - -- * first peer sharing request will be issued after - -- `policyPeerSharAcitvationDelay = 300` - -- * this request will not bring any new peers, because non of the peers - -- are yet mature - -- * inbound connections become mature at 900s (15 mins) - -- * next peer share request happens after 900s, e.g. around 1200s. - . Trace.takeWhile (\se -> case se of - SimEvent {seTime} -> seTime < Time 1250 - SimPOREvent {seTime} -> seTime < Time 1250 - _ -> False - ) - $ runSimTrace sim + . splitWithNameTrace + . fmap (\(WithTime t (WithName name b)) + -> WithName name (WithTime t b)) + . withTimeNameTraceEvents + @DiffusionTestTrace + @NtNAddr + -- We need roughly 1200 because: + -- * first peer sharing request will be issued after + -- `policyPeerSharAcitvationDelay = 300` + -- * this request will not bring any new peers, because none of + -- the peers are yet mature + -- * inbound connections become mature at 900s (15 mins) + -- * next peer share request happens after 900s, e.g. around 1200s. + . Trace.takeWhile (\se -> case se of + SimEvent {seTime} -> seTime < Time 1250 + SimPOREvent {seTime} -> seTime < Time 1250 + _ -> False + ) + $ runSimTrace sim verify :: NtNAddr -> [TracePeerSelection extraDebugState extraFlags @@ -4681,7 +4682,7 @@ splitIntoStreams :: Ord k -> [a] -> [[a]] splitIntoStreams f = Map.elems - . Map.fromListWith (\a b -> b ++ a) + . Map.fromListWith (flip (++)) . map (\a -> (fromJust (f a), [a])) . filter (isJust . f) @@ -5213,7 +5214,7 @@ toBearerInfo abi = biOutboundAttenuation = attenuation (abiOutboundAttenuation abi), biInboundWriteFailure = abiInboundWriteFailure abi, biOutboundWriteFailure = abiOutboundWriteFailure abi, - biAcceptFailures = (\(errDelay, ioErr) -> (delay errDelay, ioErr)) <$> abiAcceptFailure abi, + biAcceptFailures = first delay <$> abiAcceptFailure abi, biSDUSize = toSduSize (abiSDUSize abi) } From e3deb7f9af1509444d29965051b5f7255a377d0e Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Thu, 25 Sep 2025 20:52:14 +0200 Subject: [PATCH 17/24] Various small improvements * refactored `requireBootstrapPeers` * `unit_peer_sharing`: refactored to get debug output easier * labelled inbound governor state var --- .../Network/PeerSelection/Bootstrap.hs | 5 +-- .../Test/Cardano/Network/Diffusion/Testnet.hs | 32 +++++++++++-------- .../lib/Ouroboros/Network/InboundGovernor.hs | 2 +- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs b/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs index fdaa0175f39..ede8180b110 100644 --- a/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs +++ b/cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs @@ -34,8 +34,9 @@ isBootstrapPeersEnabled _ = True -- * When bootstrap peers are in use and the ledger is in 'TooOld' state, -- the system is considered to be in a sensitive state. requiresBootstrapPeers :: UseBootstrapPeers -> LedgerStateJudgement -> Bool -requiresBootstrapPeers ubp lsj = - isBootstrapPeersEnabled ubp && lsj == TooOld +requiresBootstrapPeers _ubp YoungEnough = False +requiresBootstrapPeers ubp TooOld = isBootstrapPeersEnabled ubp + -- | A node is able to make progress either if it isn't in a sensitive state -- _or_ if it is in a sensitive state and has reached a clean state from which diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs index 440a9802ae2..f936c2855e6 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs @@ -4342,6 +4342,7 @@ unit_peer_sharing = ) $ events' + events' :: [[WithName NtNAddr (WithTime DiffusionTestTrace)]] events' = Trace.toList . splitWithNameTrace . fmap (\(WithTime t (WithName name b)) @@ -4349,19 +4350,21 @@ unit_peer_sharing = . withTimeNameTraceEvents @DiffusionTestTrace @NtNAddr - -- We need roughly 1200 because: - -- * first peer sharing request will be issued after - -- `policyPeerSharAcitvationDelay = 300` - -- * this request will not bring any new peers, because none of - -- the peers are yet mature - -- * inbound connections become mature at 900s (15 mins) - -- * next peer share request happens after 900s, e.g. around 1200s. - . Trace.takeWhile (\se -> case se of - SimEvent {seTime} -> seTime < Time 1250 - SimPOREvent {seTime} -> seTime < Time 1250 - _ -> False - ) - $ runSimTrace sim + $ trace + + -- We need roughly 1200 because: + -- * first peer sharing request will be issued after + -- `policyPeerSharAcitvationDelay = 300` + -- * this request will not bring any new peers, because none of + -- the peers are yet mature + -- * inbound connections become mature at 900s (15 mins) + -- * next peer share request happens after 900s, e.g. around 1200s. + trace = Trace.takeWhile (\se -> case se of + SimEvent {seTime} -> seTime < Time 1_250 + SimPOREvent {seTime} -> seTime < Time 1_250 + _ -> False + ) + $ runSimTrace sim verify :: NtNAddr -> [TracePeerSelection extraDebugState extraFlags @@ -4386,7 +4389,8 @@ unit_peer_sharing = verify _ _ = Every True in - -- counterexample (ppEvents trace) $ + -- counterexample (ppTrace_ trace) $ + -- counterexample (foldr (\as out -> "===\n" ++ unlines (show <$> as) ++ out) "" events') $ counterexample (Map.foldrWithKey (\addr evs s -> concat [ "\n\n===== " , show addr , " =====\n\n" diff --git a/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs b/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs index b8dcd7cd35d..69ecc7977db 100644 --- a/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs +++ b/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs @@ -155,7 +155,6 @@ with :: forall (muxMode :: Mux.Mode) socket peerAddr initiatorCtx responderCtx , MonadMask m , Ord peerAddr , HasResponder muxMode ~ True - , MonadTraceSTM m , MonadFork m , MonadDelay m , Show peerAddr @@ -181,6 +180,7 @@ with k = do stateVar <- newTVarIO emptyState + labelTVarIO stateVar "inbound-governor-state-var" active <- newTVarIO True -- ^ inbound governor status: True = Active let connectionHandler = mkConnectionHandler $ inboundGovernorMuxTracer infoChannel From 736ff01543b7d7341a901f7f351ff2f164e1f5af Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Thu, 18 Sep 2025 17:24:58 +0200 Subject: [PATCH 18/24] Added changelog --- .../20250929_102532_coot_packages.md | 4 ++ .../20250922_173749_coot_packages.md | 30 ++++++++--- .../20250929_102712_coot_packages.md | 3 ++ .../20250918_171610_coot_packages.md | 51 +++++++++++++++++++ 4 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 cardano-client/changelog.d/20250929_102532_coot_packages.md create mode 100644 dmq-node/changelog.d/20250929_102712_coot_packages.md create mode 100644 ouroboros-network/changelog.d/20250918_171610_coot_packages.md diff --git a/cardano-client/changelog.d/20250929_102532_coot_packages.md b/cardano-client/changelog.d/20250929_102532_coot_packages.md new file mode 100644 index 00000000000..019613af2c4 --- /dev/null +++ b/cardano-client/changelog.d/20250929_102532_coot_packages.md @@ -0,0 +1,4 @@ +### Non-Breaking + +- Dependencies updated to `ouroboros-network` and `cardano-diffusion`. + diff --git a/cardano-diffusion/changelog.d/20250922_173749_coot_packages.md b/cardano-diffusion/changelog.d/20250922_173749_coot_packages.md index c69bfbbe32c..8b6692d3870 100644 --- a/cardano-diffusion/changelog.d/20250922_173749_coot_packages.md +++ b/cardano-diffusion/changelog.d/20250922_173749_coot_packages.md @@ -1,12 +1,30 @@ ### Breaking -- Initial release of `cardano-diffusion` package which is based on +- Initial release of the `cardano-diffusion` package, which is based on `ourorboros-network:cardano-diffusion` with the following modifications: - Removed `Cardano.Network.Types` module. `LedgerStateJudgement` is available - from `cardano-diffusion:api` package in + from the `cardano-diffusion:api` package in `Cardano.Network.LedgerStateJudgement` module. `NumberOfBigLedgerPeers` is - avaialble from `cardano-diffusion` in `Cardano.Network.PeerSelection` module. - - Added `Cardano.Network.PeerSelection` module which exports most of cardano - related `PeerSelection` APIs - you can simplify your imports with it. It - might be a good idea to imports this module qualified. + available from `cardano-diffusion` in `Cardano.Network.PeerSelection` module. + - Added `Cardano.Network.PeerSelection` module, which exports most of the + Cardano-related `PeerSelection` APIs - you can simplify your imports with it. + It might be a good idea to import this module qualified. +- `Cardano.Network.FetchMode` exports `ConsensusMode` and + `LedgerStateJudgement` as these are arguments of `mkReadFetchMode`. + +- `Cardano.Network.Types` module was removed. `LedgerStateJudgement` is + available from the `cardano-diffusion:api` package in + `Cardano.Network.LedgerStateJudgement` module. `NumberOfBigLedgerPeers` is + available from `cardano-diffusion` in `Cardano.Network.PeerSelection` module. + +- `Cardano.Network.PeerSelection.PeerSelectionActions.requestPublicRootPeers` + was renamed as `requestPublicRootPeersImpl` to avoid a name clash with + `PeerSelectionActions{requestPublicRootPeers}`. + +- `Cardano.Network.LedgerPeerConsensusInterface` re-exports `FetchMode`, + `LedgerStateJudgement` and `OutboundConnectionsState` since these types are + appear in `LedgerPeerConsensusInterface` record. + +- `Cardano.Network.PeerSelection.Churn` exports `PeerChurnArgs` for the + completeness sake. diff --git a/dmq-node/changelog.d/20250929_102712_coot_packages.md b/dmq-node/changelog.d/20250929_102712_coot_packages.md new file mode 100644 index 00000000000..a1b861969e6 --- /dev/null +++ b/dmq-node/changelog.d/20250929_102712_coot_packages.md @@ -0,0 +1,3 @@ +### Non-Breaking + +- Dependencies updated to `ouroboros-network` and `cardano-diffusion`. diff --git a/ouroboros-network/changelog.d/20250918_171610_coot_packages.md b/ouroboros-network/changelog.d/20250918_171610_coot_packages.md new file mode 100644 index 00000000000..c1c45e7df34 --- /dev/null +++ b/ouroboros-network/changelog.d/20250918_171610_coot_packages.md @@ -0,0 +1,51 @@ +### Breaking + +- All `ouroboros-*` where incorporated into `ouroboros-network`, at the same + time all **Cardano** specific components were pulled into `cardano-diffusion`: + + * `ouroboros-network-protocols` -> `ouroboros-network:protocols` + * `ouroboros-network-protocols:testlib` -> `ouroboros-network:protocols-tests-lib` + * `ouroboros-network-protocols:test` -> `ouroboros-network:protocols-tests` + * `ouroboros-network-protocols:bench` -> `ouroboros-network:protocols-bench` + * `ouroboros-network-framework` -> `ouroboros-network:framework` + * `ouroboros-network-framework:testlib` -> `ouroboros-network:framework-tests-lib` + * `ouroboros-network-framework:sim-tests` -> `ouroboros-network:framework-sim-tests` + * `ouroboros-network-framework:io-tests` -> `ouroboros-network:framework-io-tests` + * `ouroboros-network-framework:demo-connection-manager` -> `ouroboros-network:demo-connection-manager` + * `ouroboros-network-framework:demo-ping-pong` -> `ouroboros-network:demo-ping-pong` + * `ouroboros-newtork-mock` -> `ouroboros-network:mock` + * `ouroboros-network:testlib` -> `ouroboros-network:ouroboros-network-tests-lib` + * `ouroboros-network:sim-tests` -> `ouroboros-network:ouroboros-network-sim-tests` + * `ouroboros-network:io-tests` -> `ouroboros-network:ouroboros-network-io-tests` + * `ouroboros-network-testing` -> `ouroboros-network:tests-lib` + * `ouroboros-network-testing:test` -> `ouroboros-network:tests-lib` + * `ouroboros-network-api` -> `ouroboros-network:api` + * `ouroboros-network-api:test` -> `ouroboros-network:api-tests` + * `ouroboros-network-api:bench-anchored-fragment` -> `ouroboros-network:api-bench` + +- The following modules were moved to a different namespace: + * `ouroboros-network:api` - moved `NodeTo{Node,Client}` modules under `Cardano` namespace + * `ouroboros-network:api-tests` - moved `NodeTo{Client,Node}.Version` tests + * `ouroboros-network:api-tests` - moved Test.Cardano.Network.Version + * `ouroboros-network:mock` - moved its last module to protocols-tests-lib + +- Introduced `cardano-diffusion` package. It contains all `Cardano.Network` + namespace. + +- Added exports to `Ouroboros.Network.PeerSelection`, quite likely you can + simplify your imports. If you need Cardano-specific peer selection, try + importing from `Cardano.Network.PeerSelection` from `cardano-diffusion` + package. It re-exports almost all of `Ouroboros.Network.PeerSelection`. + +- `PeerChurnArgs{getLedgerStateCtx}` was renamed to + `PeerChurnArgs{getLedgerPeersAPI}`, to avoid a name clash with + `PeerSelectionActions{getLedgerStateCtx}`. + +- `LocalRootConfig{extraFlags}` was renamed to + `LocalRootConfig{extraLocalRootFlags}` to avoid a name clash with + `LocalRootPeersGroup{extraFlags}` field in the `Ouroboros.Network.Topology` + module. + +- `Ouroboros.Network.PeerSelection.PeerSelectionActions.requestPublicRootPeers` + was renamed as `requestPublicRootPeersImpl` to avoid a name clash with + `PeerSelectionActions{requestPublicRootPeers}`. From d454badd21adde81f7e01aca1a72fda335a62293 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Thu, 18 Sep 2025 17:39:38 +0200 Subject: [PATCH 19/24] Updated network-spec --- docs/network-spec/miniprotocols.tex | 98 +++++++++++++++-------------- docs/network-spec/network-spec.tex | 2 +- nix/network-docs.nix | 6 +- 3 files changed, 54 insertions(+), 52 deletions(-) diff --git a/docs/network-spec/miniprotocols.tex b/docs/network-spec/miniprotocols.tex index e77610ae6f7..e12c0eadbf8 100644 --- a/docs/network-spec/miniprotocols.tex +++ b/docs/network-spec/miniprotocols.tex @@ -194,8 +194,8 @@ \subsection{Handshake} {Handshake Mini Protocol} {handshake-protocol} {This protocol is used for version negotiation.} - {ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-framework/Ouroboros-Network-Protocol-Handshake-Type.html\#t:Handshake} + {ouroboros-network/framework/lib/Ouroboros/Network/Protocol/Handshake/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/framework/Ouroboros-Network-Protocol-Handshake-Type.html\#t:Handshake} \subsection{Node-to-node mini-protocols} @@ -205,36 +205,36 @@ \subsection{Node-to-node mini-protocols} {Chain Synchronisation Protocol} {chain-sync-protocol} {The protocol by which a downstream chain consumer follows an upstream chain producer.} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-ChainSync-Type.html\#t:ChainSync} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/protocols/Ouroboros-Network-Protocol-ChainSync-Type.html\#t:ChainSync} \miniEntry {Block Fetch Protocol} {block-fetch-protocol} {The block fetching mechanism enables a node to download ranges of blocks.} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/BlockFetch/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-BlockFetch-Type.html\#t:BlockFetch} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/BlockFetch/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/protocols/Ouroboros-Network-Protocol-BlockFetch-Type.html\#t:BlockFetch} \miniEntry {Transaction Submission Protocol v2} {tx-submission-protocol2} {A Protocol for transmitting transactions between core nodes.} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-TxSubmission2-Type.html\#t:TxSubmission2} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/TxSubmission2/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/protocols/Ouroboros-Network-Protocol-TxSubmission2-Type.html\#t:TxSubmission2} \miniEntry {Keep Alive Protocol} {keep-alive-protocol} {A protocol for sending keep alive messages and doing round trip measurements} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/KeepAlive/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-KeepAlive-Type.html\#t:KeepAlive} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/KeepAlive/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/protocols/Ouroboros-Network-Protocol-KeepAlive-Type.html\#t:KeepAlive} \miniEntry {Peer Sharing Protocol} {peer-sharing-protocol} {A mini-protocol which allows to share peer addresses} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/PeerSharing/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-PeerSharing-Type.html\#t:PeerSharing} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/PeerSharing/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/protocols/Ouroboros-Network-Protocol-PeerSharing-Type.html\#t:PeerSharing} \subsection{Node-to-client mini-protocols} @@ -246,29 +246,29 @@ \subsection{Node-to-client mini-protocols} {Chain Synchronisation Protocol} {chain-sync-protocol} {The protocol by which a downstream chain consumer follows an upstream chain producer.} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ChainSync/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-ChainSync-Type.html\#t:ChainSync} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/ChainSync/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/protocols/Ouroboros-Network-Protocol-ChainSync-Type.html\#t:ChainSync} \miniEntry {Local State Query Mini Protocol} {local-state-query-protocol} {Protocol used by local clients to query ledger state} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalStateQuery-Type.html\#t:LocalStateQuery} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalStateQuery/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/cardano-diffusion/protocols/Cardano-Network-Protocol-LocalStateQuery-Type.html\#t:LocalStateQuery} \miniEntry {Local Tx Submission Mini Protocol} {local-tx-submission-protocol} {Protocol used by local clients to submit transactions} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxSubmission/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalTxSubmission-Type.html\#t:LocalTxSubmission} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxSubmission/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/protocols/Ouroboros-Network-Protocol-LocalTxSubmission-Type.html\#t:LocalTxSubmission} \miniEntry {Local Tx Monitor Mini Protocol} {local-tx-monitor-protocol} {Protocol used by local clients to monitor transactions} - {ouroboros-network-protocols/src/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs} - {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalTxMonitor-Type.html\#t:LocalTxMonitor} + {ouroboros-network/protocols/lib/Ouroboros/Network/Protocol/LocalTxMonitor/Type.hs} + {https://ouroboros-network.cardano.intersectmbo.org/ouroboros-network/protocols/Ouroboros-Network-Protocol-LocalTxMonitor-Type.html\#t:LocalTxMonitor} \section{CBOR and CDDL} @@ -414,8 +414,8 @@ \subsubsection{State machine} \end{table} \section{Handshake mini-protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.Handshake.Type}{ouroboros-network-framework/Ouroboros-Network-Protocol-Handshake-Type\#t:Handshake}\\ -\codechaddockref{Ouroboros.Network.Protocol.Handshake.Codec}{ouroboros-network-framework/Ouroboros-Network-Protocol-Handshake-Codec\#v:codecHandshake}\\ +\protocolhaddockref{Ouroboros.Network.Protocol.Handshake.Type}{ouroboros-network/framework/Ouroboros-Network-Protocol-Handshake-Type.html\#t:Handshake}\\ +\codechaddockref{Ouroboros.Network.Protocol.Handshake.Codec}{ouroboros-network/framework/Ouroboros-Network-Protocol-Handshake-Codec.html\#v:codecHandshake}\\ \hyperref[table:node-to-node-protocol-numbers]{\textit{node-to-node mini-protocol number}}: \texttt{0}\\ \hyperref[table:node-to-client-protocol-numbers]{\textit{node-to-client mini-protocol number}}: \texttt{0}\\ \hyperref[sec:nodetoclientcddl]{node-to-client handshake CDDL spec} @@ -536,6 +536,7 @@ \subsection{Timeouts per state} \end{table} \subsection{Node-to-node handshake} +\codechaddockref{Cardano.Network.NodeToNode}{cardano-diffusion/Cardano-Network-NodeToNode.html\#v:nodeToNodeHandshakeCodec}\\ The node-to-node handshake instantiates version data\footnote{To be precise, in ouroboros-network, we instantiate version data to CBOR terms and do encoding @@ -605,6 +606,7 @@ \subsubsection{Timeouts per state} \end{table} \subsection{Node-to-client handshake} +\codechaddockref{Cardano.Network.NodeToClient}{cardano-diffusion/Cardano-Network-NodeToClient.html\#v:nodeToClientHandshakeCodec}\\ The node-to-node handshake instantiates version data to a record which consists of @@ -770,15 +772,15 @@ \subsection{CDDL encoding specification}\label{handshake-cddl} messages. First, one is used by the node-to-node protocol, and the other is used by the node-to-client protocol. \subsubsection{Node-to-node handshake mini-protocol} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/handshake-node-to-node-v14.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/handshake-node-to-node-v14.cddl} \subsubsection{Node-to-client handshake mini-protocol} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/handshake-node-to-client.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/handshake-node-to-client.cddl} \section{Chain-Sync mini-protocol} \label{chain-sync-protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.ChainSync.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-ChainSync-Type\#t:ChainSync}\\ -\codechaddockref{Ouroboros.Network.Protocol.ChainSync.Codec}{ouroboros-network-protocols/Ouroboros-Network-Protocol-ChainSync-Codec\#v:codecChainSync}\\ +\protocolhaddockref{Ouroboros.Network.Protocol.ChainSync.Type}{ouroboros-network/protocols/Ouroboros-Network-Protocol-ChainSync-Type.html\#t:ChainSync}\\ +\codechaddockref{Ouroboros.Network.Protocol.ChainSync.Codec}{ouroboros-network/protocols/Ouroboros-Network-Protocol-ChainSync-Codec.html\#v:codecChainSync}\\ \hyperref[table:node-to-node-protocol-numbers]{\textit{node-to-node mini-protocol number}}: \texttt{2}\\ \hyperref[table:node-to-client-protocol-numbers]{\textit{node-to-client mini-protocol number}}: \texttt{5}\\ @@ -1109,13 +1111,13 @@ \subsection{Implementation of the Chain Consumer} \end{description} \subsection{CDDL encoding specification} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/chain-sync.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/chain-sync.cddl} See appendix \ref{cddl-common} for common definitions. \section{Block-Fetch mini-protocol} \label{block-fetch-protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.BlockFetch.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-BlockFetch-Type\#t:BlockFetch}\\ -\codechaddockref{Ouroboros.Network.Protocol.BlockFetch.Codec}{ouroboros-network-protocols/Ouroboros-Network-Protocol-BlockFetch-Codec\#v:codecBlockFetch}\\ +\protocolhaddockref{Ouroboros.Network.Protocol.BlockFetch.Type}{ouroboros-network/protocols/Ouroboros-Network-Protocol-BlockFetch-Type.html\#t:BlockFetch}\\ +\codechaddockref{Ouroboros.Network.Protocol.BlockFetch.Codec}{ouroboros-network/protocols/Ouroboros-Network-Protocol-BlockFetch-Codec.html\#v:codecBlockFetch}\\ \hyperref[table:node-to-node-protocol-numbers]{\textit{node-to-node mini-protocol number}}: \texttt{3}\\ \renewcommand{\StIdle}{\state{StIdle}} @@ -1238,12 +1240,12 @@ \subsection{Timeouts per state} \end{table} \subsection{CDDL encoding specification} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/block-fetch.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/block-fetch.cddl} See appendix \ref{cddl-common} for common definitions. \section{Tx-Submission mini-protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.TxSubmission2.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-TxSubmission2-Type\#t:TxSubmission2}\\ -\codechaddockref{Ouroboros.Network.Protocol.TxSubmission2.Codec}{ouroboros-network-protocols/Ouroboros-Network-Protocol-TxSubmission2-Codec\#v:codecTxSubmission2}\\ +\protocolhaddockref{Ouroboros.Network.Protocol.TxSubmission2.Type}{ouroboros-network/protocols/Ouroboros-Network-Protocol-TxSubmission2-Type.html\#t:TxSubmission2}\\ +\codechaddockref{Ouroboros.Network.Protocol.TxSubmission2.Codec}{ouroboros-network/protocols/Ouroboros-Network-Protocol-TxSubmission2-Codec.html\#v:codecTxSubmission2}\\ \hyperref[table:node-to-node-protocol-numbers]{\textit{node-to-node mini-protocol number}}: \texttt{4}\\ \label{tx-submission-protocol} \label{tx-submission-protocol2} @@ -1469,7 +1471,7 @@ \subsection{Timeouts per state} \end{table} \subsection{CDDL encoding specification}\label{tx-submission2-cddl} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/tx-submission2.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/tx-submission2.cddl} \subsection{Client and Server Implementation} The protocol has two design goals: It must diffuse transactions with high efficiency @@ -1514,8 +1516,8 @@ \subsection{Client and Server Implementation} A blocking request, on the other side, waits until at least one transaction is available. \section{Keep Alive Mini Protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.KeepAlive.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-KeepAlive-Type\#t:KeepAlive}\\ -\codechaddockref{Ouroboros.Network.Protocol.KeepAlive.Codec}{ouroboros-network-protocols/Ouroboros-Network-Protocol-KeepAlive-Codec\#v:codecKeepAlive\_v2}\\ +\protocolhaddockref{Ouroboros.Network.Protocol.KeepAlive.Type}{ouroboros-network/protocols/Ouroboros-Network-Protocol-KeepAlive-Type.html\#t:KeepAlive}\\ +\codechaddockref{Ouroboros.Network.Protocol.KeepAlive.Codec}{ouroboros-network/protocols/Ouroboros-Network-Protocol-KeepAlive-Codec.html\#v:codecKeepAlive\_v2}\\ \hyperref[table:node-to-node-protocol-numbers]{\textit{node-to-node mini-protocol number}}: \texttt{8}\\ \label{keep-alive-protocol} @@ -1604,11 +1606,11 @@ \subsection{Timeouts per state} \end{table} \subsection{CDDL encoding specification} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/keep-alive.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/keep-alive.cddl} \section{Peer Sharing mini-protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.PeerSharing.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-PeerSharing-Type\#t:PeerSharing}\\ -\codechaddockref{Ouroboros.Network.Protocol.PeerSharing.Codec}{ouroboros-network-protocols/Ouroboros-Network-Protocol-PeerSharing-Codec\#v:codecPeerSharing}\\ +\protocolhaddockref{Ouroboros.Network.Protocol.PeerSharing.Type}{ouroboros-network/protocols/Ouroboros-Network-Protocol-PeerSharing-Type.html\#t:PeerSharing}\\ +\codechaddockref{Ouroboros.Network.Protocol.PeerSharing.Codec}{ouroboros-network/protocols/Ouroboros-Network-Protocol-PeerSharing-Codec.html\#v:codecPeerSharing}\\ \hyperref[table:node-to-node-protocol-numbers]{\textit{node-to-node mini-protocol number}}: \texttt{10}\\ \label{peer-sharing-protocol} \subsection{Description} @@ -1766,11 +1768,11 @@ \subsection{Server Implementation Details} \texttt{PeerSelectionState} with this function via a \texttt{TVar}. \subsection{CDDL encoding specification ($\geq 14$)}\label{peersharing-cddl} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/peer-sharing-v14.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/peer-sharing-v14.cddl} \section{Local Tx-Submission mini-protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.LocalTxSubmission.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalTxSubmission-Type\#t:LocalTxSubmission}\\ -\codechaddockref{Ouroboros.Network.Protocol.LocalTxSubmission.Codec}{ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalTxSubmission-Codec\#v:codecLocalTxSubmission}\\ +\protocolhaddockref{Ouroboros.Network.Protocol.LocalTxSubmission.Type}{ouroboros-network/protocols/Ouroboros-Network-Protocol-LocalTxSubmission-Type.html\#t:LocalTxSubmission}\\ +\codechaddockref{Ouroboros.Network.Protocol.LocalTxSubmission.Codec}{ouroboros-network/protocols/Ouroboros-Network-Protocol-LocalTxSubmission-Codec.html\#v:codecLocalTxSubmission}\\ \hyperref[table:node-to-client-protocol-numbers]{\textit{node-to-client mini-protocol number}}: \texttt{6}\\ \label{local-tx-submission-protocol} \subsection{Description} @@ -1842,13 +1844,13 @@ \subsection{Timeouts per state} No timeouts. \subsection{CDDL encoding specification} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/local-tx-submission.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/local-tx-submission.cddl} See appendix \ref{cddl-common} for common definitions. \section{Local State Query mini-protocol} \label{local-state-query-protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.LocalStateQuery.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalStateQuery-Type\#t:LocalStateQuery}\\ -\codechaddockref{Ouroboros.Network.Protocol.LocalStateQuery.Codec}{ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalStateQuery-Codec\#v:codecLocalStateQuery}\\ +\protocolhaddockref{Cardano.Network.Protocol.LocalStateQuery.Type}{cardano-diffusion/protocols/Cardano-Network-Protocol-LocalStateQuery-Type.html\#t:LocalStateQuery}\\ +\codechaddockref{Cardano.Network.Protocol.LocalStateQuery.Codec}{cardano-diffusion/protocols/Cardano-Network-Protocol-LocalStateQuery-Codec.html\#v:codecLocalStateQuery}\\ \hyperref[table:node-to-client-protocol-numbers]{\textit{node-to-client mini-protocol number}}: \texttt{7}\\ \newcommand{\StAcquiring}{\state{Acquiring}} \newcommand{\StAcquired}{\state{Acquired}} @@ -1976,12 +1978,12 @@ \subsection{Timeouts per state} No timeouts. \subsection{CDDL encoding specification} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/local-state-query.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/local-state-query.cddl} See appendix \ref{cddl-common} for common definitions. \section{Local Tx-Monitor mini-protocol} -\protocolhaddockref{Ouroboros.Network.Protocol.LocalTxMonitor.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalTxMonitor-Type\#t:LocalTxMonitor}\\ -\codechaddockref{Ouroboros.Network.Protocol.LocalTxMonitor.Codec}{ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalTxMonitor-Codec\#v:codecLocalTxMonitor}\\ +\protocolhaddockref{Cardano.Network.Protocol.LocalTxMonitor.Type}{cardano-diffusion/protocols/Cardano-Network-Protocol-LocalTxMonitor-Type.html\#t:LocalTxMonitor}\\ +\codechaddockref{Cardano.Network.Protocol.LocalTxMonitor.Codec}{cardano-diffusion/protocols/Cardano-Network-Protocol-LocalTxMonitor-Codec.html\#v:codecLocalTxMonitor}\\ \hyperref[table:node-to-client-protocol-numbers]{\textit{node-to-client mini-protocol number}}: \texttt{9}\\ \label{local-tx-monitor-protocol} \newcommand{\MsgAwaitAcquire}{\msg{MsgAwaitAcquire}} @@ -2130,7 +2132,7 @@ \subsection{Timeouts per state} No timeouts. \subsection{CDDL encoding specification} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/local-tx-monitor.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/local-tx-monitor.cddl} See appendix \ref{cddl-common} for common definitions. \section{Pipelining of Mini Protocols} diff --git a/docs/network-spec/network-spec.tex b/docs/network-spec/network-spec.tex index 27632bdbe4d..e63a92ba426 100644 --- a/docs/network-spec/network-spec.tex +++ b/docs/network-spec/network-spec.tex @@ -211,7 +211,7 @@ \chapter{Common CDDL definitions} \label{cddl-common} -\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/network.base.cddl} +\lstinputlisting[style=cddl]{../../cardano-diffusion/protocols/cddl/specs/network.base.cddl} \chapter{Historical protocol versions} \label{historical-protocol-versions} diff --git a/nix/network-docs.nix b/nix/network-docs.nix index 7acf6e30a56..ea96afc045b 100644 --- a/nix/network-docs.nix +++ b/nix/network-docs.nix @@ -14,7 +14,7 @@ inputs: final: prev: { buildPhase = let src = ../.; - cddl-specs = ../ouroboros-network-protocols/cddl/specs; + cddl-specs = ../cardano-diffusion/protocols/cddl/specs; in '' for d in network-design network-spec; do @@ -24,8 +24,8 @@ inputs: final: prev: { touch docs/network-spec/.isRelease - mkdir -p ouroboros-network-protocols/cddl/specs - cp ${cddl-specs}/*.cddl ouroboros-network-protocols/cddl/specs + mkdir -p cardano-diffusion/protocols/cddl/specs + cp ${cddl-specs}/*.cddl cardano-diffusion/protocols/cddl/specs mkdir -p $out From ec3c0fb924be5b61f385556ec68d3918c953efac Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Mon, 29 Sep 2025 12:38:15 +0200 Subject: [PATCH 20/24] dmq-node: renamed dmq-test component as dmq-tests This is inline with other testing component in `ouroboros-network` repository. --- .github/workflows/build.yml | 10 +++++----- dmq-node/dmq-node.cabal | 2 +- nix/ouroboros-network.nix | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 86a63151df2..e32b28ff5a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -136,11 +136,11 @@ jobs: if: runner.os != 'Windows' run: cabal run ouroboros-network:ouroboros-network-sim-tests -- +RTS -maxN2 -RTS - - name: cardano-diffusion:protocols-tests + - name: cardano-diffusion [protocols-tests] if: runner.os != 'Windows' run: cabal run cardano-diffusion:protocols-tests -- +RTS -maxN2 -RTS - - name: cardano-diffusion:api-tests + - name: cardano-diffusion [api-tests] if: runner.os != 'Windows' run: cabal run cardano-diffusion:api-tests -- +RTS -maxN2 -RTS @@ -148,12 +148,12 @@ jobs: if: runner.os != 'Windows' run: cabal run cardano-diffusion:protocols-tests -- +RTS -maxN2 -RTS - - name: cardano-diffusion:cardano-diffusion-sim-test + - name: cardano-diffusion [cardano-diffusion-sim-test] if: runner.os != 'Windows' run: cabal run cardano-diffusion:cardano-diffusion-sim-tests -- +RTS -maxN2 -RTS - - name: dmq-node [test] - run: cabal run dmq-node:dmq-test -- +RTS -maxN2 -RTS + - name: dmq-node [dmq-tests] + run: cabal run dmq-node:dmq-tests -- +RTS -maxN2 -RTS # Uncomment the following back in for debugging. Remember to launch a `pwsh` from # the tmux session to debug `pwsh` issues. And be reminded that the `/msys2` and diff --git a/dmq-node/dmq-node.cabal b/dmq-node/dmq-node.cabal index d31a75489fd..42cf76e6d8a 100644 --- a/dmq-node/dmq-node.cabal +++ b/dmq-node/dmq-node.cabal @@ -141,7 +141,7 @@ executable dmq-node hs-source-dirs: app default-language: Haskell2010 -test-suite dmq-test +test-suite dmq-tests import: warnings, extensions diff --git a/nix/ouroboros-network.nix b/nix/ouroboros-network.nix index 127176efa3d..df42808d581 100644 --- a/nix/ouroboros-network.nix +++ b/nix/ouroboros-network.nix @@ -113,8 +113,7 @@ let packages.ouroboros-network.components.tests.framework-sim-tests.doCheck = onLinux; packages.ouroboros-network.components.tests.ouroboros-network-sim-tests.doCheck = onLinux; - - packages.dmq-node.components.tests.dmq-test.preCheck = + packages.dmq-node.components.tests.dmq-tests.preCheck = if buildSystem == "x86_64-linux" then "export GHCRTS=-M1600M" else ""; packages.network-mux.components.tests.test.preCheck = if buildSystem == "x86_64-linux" then "export GHCRTS=-M800M" else ""; From ba10a75cbba6ddc2cf78fe16663f0b78c1101464 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Mon, 29 Sep 2025 16:48:58 +0200 Subject: [PATCH 21/24] Removed `DuplicateRecordFields` extension We don't need to disambiguate record fields anymore. --- .../Cardano/Network/PeerSelection/Churn.hs | 13 ++-- .../Network/PeerSelection/MockEnvironment.hs | 14 ++--- dmq-node/src/DMQ/Diffusion/Applications.hs | 29 +++++---- .../lib/Ouroboros/Network/InboundGovernor.hs | 23 ++++---- .../lib/Ouroboros/Network/Diffusion.hs | 59 +++++++++---------- .../Ouroboros/Network/Diffusion/Topology.hs | 3 +- .../lib/Ouroboros/Network/PeerSelection.hs | 3 - .../Ouroboros/Network/PeerSelection/Churn.hs | 13 ++-- .../Network/PeerSelection/Governor.hs | 13 ++-- .../Network/PeerSelection/LedgerPeers.hs | 17 +++--- 10 files changed, 87 insertions(+), 100 deletions(-) diff --git a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs index b225eb2de5a..54b480fea34 100644 --- a/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs +++ b/cardano-diffusion/lib/Cardano/Network/PeerSelection/Churn.hs @@ -1,10 +1,9 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE ScopedTypeVariables #-} #if __GLASGOW_HASKELL__ < 904 {-# OPTIONS_GHC -Wno-name-shadowing #-} diff --git a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs index e6a8c18a8ff..f8f30cd19ae 100644 --- a/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs +++ b/cardano-diffusion/tests/lib/Test/Cardano/Network/PeerSelection/MockEnvironment.hs @@ -1,15 +1,13 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -Wno-orphans #-} {-# OPTIONS_GHC -Wno-deferred-out-of-scope-variables #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -{-# LANGUAGE TypeApplications #-} -- TODO: MockEnvironment should be generalised so we can put it in -- `ouroboros-network` and test various extensions of `PeerSelection`. diff --git a/dmq-node/src/DMQ/Diffusion/Applications.hs b/dmq-node/src/DMQ/Diffusion/Applications.hs index abb30df9638..071f9ebb758 100644 --- a/dmq-node/src/DMQ/Diffusion/Applications.hs +++ b/dmq-node/src/DMQ/Diffusion/Applications.hs @@ -1,6 +1,5 @@ -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE NamedFieldPuns #-} module DMQ.Diffusion.Applications where @@ -40,15 +39,15 @@ diffusionApplications dmqcNetworkMagic = I networkMagic } Diffusion.Configuration { - dcMode - , dcPeerSharing + Diffusion.dcMode + , Diffusion.dcPeerSharing } ntnLimitsAndTimeouts ntnApps ntcApps peerSelectionPolicy = Diffusion.Applications { - daApplicationInitiatorMode = + Diffusion.daApplicationInitiatorMode = combineVersions [ simpleSingletonVersions version @@ -56,7 +55,7 @@ diffusionApplications (NTN.initiatorProtocols ntnLimitsAndTimeouts ntnApps version) | version <- [minBound..maxBound] ] - , daApplicationInitiatorResponderMode = + , Diffusion.daApplicationInitiatorResponderMode = combineVersions [ simpleSingletonVersions version @@ -64,7 +63,7 @@ diffusionApplications (NTN.initiatorAndResponderProtocols ntnLimitsAndTimeouts ntnApps version) | version <- [minBound..maxBound] ] - , daLocalResponderApplication = + , Diffusion.daLocalResponderApplication = combineVersions [ simpleSingletonVersions version @@ -72,13 +71,13 @@ diffusionApplications (NTC.responders ntcApps version) | version <- [minBound..maxBound] ] - , daRethrowPolicy = muxErrorRethrowPolicy - <> ioErrorRethrowPolicy - , daReturnPolicy = const dmqRepromoteDelay - , daRepromoteErrorDelay = dmqRepromoteDelay - , daLocalRethrowPolicy = mempty - , daPeerSelectionPolicy = peerSelectionPolicy - , daPeerSharingRegistry = peerSharingRegistry + , Diffusion.daRethrowPolicy = muxErrorRethrowPolicy + <> ioErrorRethrowPolicy + , Diffusion.daReturnPolicy = const dmqRepromoteDelay + , Diffusion.daRepromoteErrorDelay = dmqRepromoteDelay + , Diffusion.daLocalRethrowPolicy = mempty + , Diffusion.daPeerSelectionPolicy = peerSelectionPolicy + , Diffusion.daPeerSharingRegistry = peerSharingRegistry } diff --git a/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs b/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs index 69ecc7977db..20c2f480e7b 100644 --- a/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs +++ b/ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs @@ -1,15 +1,14 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE BlockArguments #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeOperators #-} -- 'runResponder' is using a redundant constraint. {-# OPTIONS_GHC -Wno-redundant-constraints #-} diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs index fb44072b467..1175259bacd 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion.hs @@ -1,14 +1,13 @@ -{-# LANGUAGE BlockArguments #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeOperators #-} -- | This module is expected to be imported qualified. -- @@ -384,17 +383,17 @@ runM Interfaces Server.snocket = diNtcSnocket, Server.tracer = dtLocalServerTracer, Server.connectionLimits = localConnectionLimits, - inboundGovernorArgs = + Server.inboundGovernorArgs = IG.Arguments { - tracer = dtLocalInboundGovernorTracer, - transitionTracer = nullTracer, - debugTracer = nullTracer, - connectionDataFlow = ntcDataFlow, - idleTimeout = Nothing, - withConnectionManager = localWithConnectionManager localInbInfoChannel, - mkConnectionHandler = mkLocalConnectionHandler, - infoChannel = localInbInfoChannel - } + IG.tracer = dtLocalInboundGovernorTracer, + IG.transitionTracer = nullTracer, + IG.debugTracer = nullTracer, + IG.connectionDataFlow = ntcDataFlow, + IG.idleTimeout = Nothing, + IG.withConnectionManager = localWithConnectionManager localInbInfoChannel, + IG.mkConnectionHandler = mkLocalConnectionHandler, + IG.infoChannel = localInbInfoChannel + } } (\inboundGovernorThread _ _ -> Async.wait inboundGovernorThread) @@ -731,19 +730,19 @@ runM Interfaces Server.tracer = dtServerTracer, Server.connectionLimits = dcAcceptedConnectionsLimit, - inboundGovernorArgs = + Server.inboundGovernorArgs = IG.Arguments { - tracer = dtInboundGovernorTracer, - transitionTracer = dtInboundGovernorTransitionTracer, - debugTracer = nullTracer, - connectionDataFlow = daNtnDataFlow, - idleTimeout = Just dcProtocolIdleTimeout, - withConnectionManager = + IG.tracer = dtInboundGovernorTracer, + IG.transitionTracer = dtInboundGovernorTransitionTracer, + IG.debugTracer = nullTracer, + IG.connectionDataFlow = daNtnDataFlow, + IG.idleTimeout = Just dcProtocolIdleTimeout, + IG.withConnectionManager = withConnectionManagerInitiatorAndResponderMode inboundInfoChannel, - mkConnectionHandler = + IG.mkConnectionHandler = makeConnectionHandler' daApplicationInitiatorResponderMode . MuxInitiatorResponderConnectionHandler daNtnDataFlow, - infoChannel = inboundInfoChannel + IG.infoChannel = inboundInfoChannel } } diff --git a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs index fd595a7b8cd..bded6a924a8 100644 --- a/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs +++ b/ouroboros-network/lib/Ouroboros/Network/Diffusion/Topology.hs @@ -1,5 +1,4 @@ -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE NamedFieldPuns #-} module Ouroboros.Network.Diffusion.Topology where diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs index 18bbec01766..9658449b820 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection.hs @@ -1,6 +1,3 @@ -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE ExplicitNamespaces #-} - module Ouroboros.Network.PeerSelection ( module Governor , module PeerSelection diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs index d20ba5d6f1e..6c345c7db53 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Churn.hs @@ -1,10 +1,9 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE ScopedTypeVariables #-} #if __GLASGOW_HASKELL__ < 904 {-# OPTIONS_GHC -Wno-name-shadowing #-} diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs index 049604acbe7..dd9904e7bd1 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/Governor.hs @@ -1,10 +1,9 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE ScopedTypeVariables #-} #if __GLASGOW_HASKELL__ < 904 {-# OPTIONS_GHC -Wno-name-shadowing #-} diff --git a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/LedgerPeers.hs b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/LedgerPeers.hs index 87594f5d948..17141285f20 100644 --- a/ouroboros-network/lib/Ouroboros/Network/PeerSelection/LedgerPeers.hs +++ b/ouroboros-network/lib/Ouroboros/Network/PeerSelection/LedgerPeers.hs @@ -1,12 +1,11 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} #if __GLASGOW_HASKELL__ >= 908 {-# OPTIONS_GHC -Wno-x-partial #-} #endif From a735c42237cf299e0141f18dfee1e123e6728ba1 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Mon, 29 Sep 2025 16:53:08 +0200 Subject: [PATCH 22/24] Moved `cardano-client` package to `cardano-diffusion:subscription` --- cabal.project | 1 - cardano-client/CHANGELOG.md | 142 -------------- cardano-client/LICENSE | 177 ------------------ cardano-client/NOTICE | 14 -- cardano-client/cardano-client.cabal | 43 ----- .../20250929_102532_coot_packages.md | 4 - cardano-client/changelog.d/scriv.ini | 15 -- cardano-diffusion/cardano-diffusion.cabal | 18 ++ .../Cardano/Client/Subscription.hs | 0 scripts/ci/run-stylish-haskell.sh | 1 - 10 files changed, 18 insertions(+), 397 deletions(-) delete mode 100644 cardano-client/CHANGELOG.md delete mode 100644 cardano-client/LICENSE delete mode 100644 cardano-client/NOTICE delete mode 100644 cardano-client/cardano-client.cabal delete mode 100644 cardano-client/changelog.d/20250929_102532_coot_packages.md delete mode 100644 cardano-client/changelog.d/scriv.ini rename {cardano-client/src => cardano-diffusion/subscription}/Cardano/Client/Subscription.hs (100%) diff --git a/cabal.project b/cabal.project index 2fe9851d5dd..d89ffe33196 100644 --- a/cabal.project +++ b/cabal.project @@ -26,7 +26,6 @@ packages: ./cardano-ping ./ouroboros-network ./cardano-diffusion ./ntp-client - ./cardano-client ./dmq-node ./acts-generic diff --git a/cardano-client/CHANGELOG.md b/cardano-client/CHANGELOG.md deleted file mode 100644 index bdbd3a57128..00000000000 --- a/cardano-client/CHANGELOG.md +++ /dev/null @@ -1,142 +0,0 @@ -# cardano-client changelog - - - - -## 0.6.1.0 -- 2025-09-10 - -* Support `ouroboros-network-0.22` - -## 0.6.0.0 -- 2025-06-28 - -### Breaking changes - -* SubscriptionTracers: mux tracer was split into two parts. - -### Non-breaking changes - -* Updated to `io-classes-1.8` - -## 0.5.2.0 -- 2025-05-23 - -### Non-breaking changes - -* Fixed how asynchronous exceptions are handled. - -## 0.5.1.1 -- 2025-05-13 - -### Breaking changes - -### Non-breaking changes - -* bump dependencies - -## 0.5.1.0 -- 2025-03-25 - -### Non-breaking changes - -* Export `Decision` type. - -## 0.5.0.0 -- 2025-01-02 - -### Breaking changes - -* Addapted to `network-mux` changes in https://github.com/IntersectMBO/ouroboros-network/pull/4997 - -## 0.4.0.0 -- 2024-10-17 - -### Breaking changes - -* Reimplementation of `subscribe` without relaying on non-p2p stack. Its - arguments have changed. Note that the `NodeToClientProtocols` and - `OuroborosApplicationWithMinimalCtx` specify `Void` as return type of the - responder side. -* The default reconnect delay was increased from `0.025s` to `5s`. - -## 0.3.1.6 -- 2024-10-11 - -### Breaking changes - -### Non-breaking changes - -* bump for version bounds - -## 0.3.1.5 -- 2024-08-27 - -### Breaking changes - -### Non-breaking changes - -* bump for bad ref in chap for 0.3.1.4 - -## 0.3.1.4 -- 2024-08-22 - -### Breaking changes - -### Non-breaking changes - -* version bump for build depends - -## 0.3.1.3 -- 2024-08-07 - -### Breaking changes - -### Non-breaking changes - -* Make it build with ghc-9.10 - -## 0.3.1.2 - -### Non-breaking changes - -* Updated bounds - -## 0.3.1.1 - -### Non-breaking changes - -* Updated bounds - -## 0.3.1.0 - -### Non-breaking changes - -* ghc-9.8 support. - -## 0.3.0.2 - -### Non-breaking changes - -* Updated package bounds. - -## 0.3.0.1 -- 2023-10-26 - -### Non-breaking changes - -* Updated bounds. - -## 0.3.0.0 -- 2023-08-09 - -### Breaking changes - -* Due to changes in `RunMiniProtocol`, `OuroborosApplication` and - `NodeToClientProtocols` data types the API provided in this package has - breaking changes. For more details see recent changes in - [`ouroboros-network-framework`][onf-changelog]. - -## 0.2.0.0 -- 2023-04-25 - -### Breaking changes - -* Make `cardano-client` independent of `ouroboros-consensus-diffusion`. Look - at haddocks how to upgrade. - -## 0.1.0.2 -- 2023-01-25 - -* Update dependencies after repository restructure - -## 0.1.0.0 -- 2020-05-18 - -* Initial release - -[onf-changelog]: https://github.com/intersectmbo/ouroboros-network/blob/master/ouroboros-network-framework/CHANGELOG.md diff --git a/cardano-client/LICENSE b/cardano-client/LICENSE deleted file mode 100644 index f433b1a53f5..00000000000 --- a/cardano-client/LICENSE +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/cardano-client/NOTICE b/cardano-client/NOTICE deleted file mode 100644 index 80eb831b9f2..00000000000 --- a/cardano-client/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2020-2023 Input Output Global Inc (IOG), Intersect 2025 - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/cardano-client/cardano-client.cabal b/cardano-client/cardano-client.cabal deleted file mode 100644 index 10cf8d4cf7f..00000000000 --- a/cardano-client/cardano-client.cabal +++ /dev/null @@ -1,43 +0,0 @@ -cabal-version: 3.0 -name: cardano-client -version: 0.6.1.0 -synopsis: An API for ouroboros-network -description: An API for ouroboros-network. -license: Apache-2.0 -license-files: - LICENSE - NOTICE - -copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2025 Intersect -author: IOHK Engineering Team -maintainer: marcin.szamotulski@iohk.io -category: Network -build-type: Simple -extra-doc-files: CHANGELOG.md - -library - hs-source-dirs: src - exposed-modules: Cardano.Client.Subscription - default-language: Haskell2010 - default-extensions: ImportQualifiedPost - build-depends: - base >=4.14 && <4.22, - bytestring >=0.10 && <0.13, - cardano-diffusion ^>=0.1, - cborg >=0.2.8 && <0.3, - containers >=0.5 && <0.9, - contra-tracer >=0.1 && <0.3, - io-classes:si-timers ^>=1.8.0.1, - network-mux ^>=0.9, - ouroboros-network:{api, framework} ^>=0.23, - - ghc-options: - -Wall - -Wno-unticked-promoted-constructors - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wunused-packages diff --git a/cardano-client/changelog.d/20250929_102532_coot_packages.md b/cardano-client/changelog.d/20250929_102532_coot_packages.md deleted file mode 100644 index 019613af2c4..00000000000 --- a/cardano-client/changelog.d/20250929_102532_coot_packages.md +++ /dev/null @@ -1,4 +0,0 @@ -### Non-Breaking - -- Dependencies updated to `ouroboros-network` and `cardano-diffusion`. - diff --git a/cardano-client/changelog.d/scriv.ini b/cardano-client/changelog.d/scriv.ini deleted file mode 100644 index c7c9a0c0b26..00000000000 --- a/cardano-client/changelog.d/scriv.ini +++ /dev/null @@ -1,15 +0,0 @@ -[scriv] -format = md -insert_marker = Changelog entries -md_header_level = 2 -version = literal: cardano-client.cabal: version -categories = Breaking, Non-Breaking -start_marker = scriv-insert-here -end_marker = scriv-end-here -fragment_directory = changelog.d -ghrel_template = {{body}} -main_branches = main -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = CHANGELOG.${config:format} -skip_fragments = README.* -entry_title_template = {%% if version %%}{{ version }} -- {%% endif %%}{{ date.strftime('%%Y-%%m-%%d') }} diff --git a/cardano-diffusion/cardano-diffusion.cabal b/cardano-diffusion/cardano-diffusion.cabal index efb4eda9b55..7b1eb44914b 100644 --- a/cardano-diffusion/cardano-diffusion.cabal +++ b/cardano-diffusion/cardano-diffusion.cabal @@ -495,3 +495,21 @@ test-suite cardano-diffusion-sim-tests +RTS -T -RTS + +library subscription + import: ghc-options + visibility: public + hs-source-dirs: subscription + exposed-modules: Cardano.Client.Subscription + default-language: Haskell2010 + default-extensions: ImportQualifiedPost + build-depends: + base >=4.14 && <4.22, + bytestring >=0.10 && <0.13, + cardano-diffusion ^>=0.1, + cborg >=0.2.8 && <0.3, + containers >=0.5 && <0.9, + contra-tracer >=0.1 && <0.3, + io-classes:si-timers ^>=1.8.0.1, + network-mux ^>=0.9, + ouroboros-network:{api, framework} ^>=0.23, diff --git a/cardano-client/src/Cardano/Client/Subscription.hs b/cardano-diffusion/subscription/Cardano/Client/Subscription.hs similarity index 100% rename from cardano-client/src/Cardano/Client/Subscription.hs rename to cardano-diffusion/subscription/Cardano/Client/Subscription.hs diff --git a/scripts/ci/run-stylish-haskell.sh b/scripts/ci/run-stylish-haskell.sh index d27be8df9c0..e562f2f29bb 100755 --- a/scripts/ci/run-stylish-haskell.sh +++ b/scripts/ci/run-stylish-haskell.sh @@ -65,7 +65,6 @@ FD_OPTS="-e hs --ignore-file ./scripts/ci/check-stylish-ignore -X stylish-haskel fd . './network-mux' $FD_OPTS fd . './ouroboros-network' $FD_OPTS fd . './cardano-diffusion' $FD_OPTS -fd . './cardano-client' $FD_OPTS fd . './dmq-node' $FD_OPTS if [ $USE_GIT == 1 ]; then From a4c977e58a220e3c189af6de967e941a578f8db6 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 7 Oct 2025 18:45:28 +0200 Subject: [PATCH 23/24] tx-submission: removed unused module It is a left over after merging tx-submission logic. The module was moved to `Ouroboros.Network.TxSubmission.Inbound.V1`. --- .../Ouroboros/Network/TxSubmission/Inbound.hs | 534 ------------------ 1 file changed, 534 deletions(-) delete mode 100644 ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound.hs diff --git a/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound.hs b/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound.hs deleted file mode 100644 index 8970edb2ea5..00000000000 --- a/ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound.hs +++ /dev/null @@ -1,534 +0,0 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE ScopedTypeVariables #-} - -{-# OPTIONS_GHC -Wno-partial-fields #-} - -module Ouroboros.Network.TxSubmission.Inbound - ( txSubmissionInbound - , TxSubmissionMempoolWriter (..) - , TraceTxSubmissionInbound (..) - , TxSubmissionProtocolError (..) - , ProcessedTxCount (..) - ) where - -import Data.Foldable as Foldable (foldl', toList) -import Data.List.NonEmpty qualified as NonEmpty -import Data.Map.Strict (Map) -import Data.Map.Strict qualified as Map -import Data.Maybe -import Data.Sequence.Strict (StrictSeq) -import Data.Sequence.Strict qualified as Seq -import Data.Set qualified as Set -import Data.Word (Word16) -import GHC.Generics (Generic) -import NoThunks.Class (NoThunks (..), unsafeNoThunks) - -import Cardano.Prelude (forceElemsToWHNF) - -import Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked -import Control.Exception (assert) -import Control.Monad (unless) -import Control.Monad.Class.MonadSTM -import Control.Monad.Class.MonadThrow -import Control.Monad.Class.MonadTimer.SI -import Control.Tracer (Tracer, traceWith) - -import Network.TypedProtocol.Core (N, Nat (..), natToInt) - -import Ouroboros.Network.NodeToNode.Version (NodeToNodeVersion) -import Ouroboros.Network.Protocol.Limits -import Ouroboros.Network.Protocol.TxSubmission2.Server -import Ouroboros.Network.Protocol.TxSubmission2.Type -import Ouroboros.Network.TxSubmission.Mempool.Reader (MempoolSnapshot (..), - TxSubmissionMempoolReader (..)) - --- | The consensus layer functionality that the inbound side of the tx --- submission logic requires. --- --- This is provided to the tx submission logic by the consensus layer. --- -data TxSubmissionMempoolWriter txid tx idx m = - TxSubmissionMempoolWriter { - - -- | Compute the transaction id from a transaction. - -- - -- This is used in the protocol handler to verify a full transaction - -- matches a previously given transaction id. - -- - txId :: tx -> txid, - - -- | Supply a batch of transactions to the mempool. They are either - -- accepted or rejected individually, but in the order supplied. - -- - -- The 'txid's of all transactions that were added successfully are - -- returned. - mempoolAddTxs :: [tx] -> m [txid] - } - -data ProcessedTxCount = ProcessedTxCount { - -- | Just accepted this many transactions. - ptxcAccepted :: Int - -- | Just rejected this many transactions. - , ptxcRejected :: Int - } - deriving (Eq, Show) - -data TraceTxSubmissionInbound txid tx = - -- | Number of transactions just about to be inserted. - TraceTxSubmissionCollected Int - -- | Just processed transaction pass/fail breakdown. - | TraceTxSubmissionProcessed ProcessedTxCount - -- | Server received 'MsgDone' - | TraceTxInboundTerminated - | TraceTxInboundCanRequestMoreTxs Int - | TraceTxInboundCannotRequestMoreTxs Int - deriving (Eq, Show) - -data TxSubmissionProtocolError = - ProtocolErrorTxNotRequested - | ProtocolErrorTxIdsNotRequested - deriving Show - -instance Exception TxSubmissionProtocolError where - displayException ProtocolErrorTxNotRequested = - "The peer replied with a transaction we did not ask for." - displayException ProtocolErrorTxIdsNotRequested = - "The peer replied with more txids than we asked for." - - --- | Information maintained internally in the 'txSubmissionInbound' server --- implementation. --- -data ServerState txid tx = ServerState { - -- | The number of transaction identifiers that we have requested but - -- which have not yet been replied to. We need to track this it keep - -- our requests within the limit on the number of unacknowledged txids. - -- - requestedTxIdsInFlight :: !Word16, - - -- | Those transactions (by their identifier) that the client has told - -- us about, and which we have not yet acknowledged. This is kept in - -- the order in which the client gave them to us. This is the same order - -- in which we submit them to the mempool (or for this example, the final - -- result order). It is also the order we acknowledge in. - unacknowledgedTxIds :: !(StrictSeq txid), - - -- | Those transactions (by their identifier) that we can request. These - -- are a subset of the 'unacknowledgedTxIds' that we have not yet - -- requested. This is not ordered to illustrate the fact that we can - -- request txs out of order. We also remember the size. - availableTxids :: !(Map txid SizeInBytes), - - -- | Transactions we have successfully downloaded but have not yet added - -- to the mempool or acknowledged. This needed because we can request - -- transactions out of order but must use the original order when adding - -- to the mempool or acknowledging transactions. - -- - -- However, it's worth noting that, in a few situations, some of the - -- transaction IDs in this 'Map' may be mapped to 'Nothing': - -- - -- * Transaction IDs mapped to 'Nothing' can represent transaction IDs - -- that were requested, but not received. This can occur because the - -- client will not necessarily send all of the transactions that we - -- asked for, but we still need to acknowledge those transactions. - -- - -- For example, if we request a transaction that no longer exists in - -- the client's mempool, the client will just exclude it from the - -- response. However, we still need to acknowledge it (i.e. remove it - -- from the 'unacknowledgedTxIds') in order to note that we're no - -- longer awaiting receipt of that transaction. - -- - -- * Transaction IDs mapped to 'Nothing' can represent transactions - -- that were not requested from the client because they're already - -- in the mempool. - -- - -- For example, if we request some transaction IDs and notice that - -- some subset of them have are already in the mempool, we wouldn't - -- want to bother asking for those specific transactions. Therefore, - -- we would just insert those transaction IDs mapped to 'Nothing' to - -- the 'bufferedTxs' such that those transactions are acknowledged, - -- but never actually requested. - -- - bufferedTxs :: !(Map txid (Maybe tx)), - - -- | The number of transactions we can acknowledge on our next request - -- for more transactions. The number here have already been removed from - -- 'unacknowledgedTxIds'. - -- - numTxsToAcknowledge :: !Word16 - } - deriving (Show, Generic) - -instance ( NoThunks txid - , NoThunks tx - ) => NoThunks (ServerState txid tx) - -initialServerState :: ServerState txid tx -initialServerState = ServerState 0 Seq.empty Map.empty Map.empty 0 - - -txSubmissionInbound - :: forall txid tx idx m. - ( Ord txid - , NoThunks txid - , NoThunks tx - , MonadSTM m - , MonadThrow m - , MonadDelay m - ) - => Tracer m (TraceTxSubmissionInbound txid tx) - -> NumTxIdsToAck -- ^ Maximum number of unacknowledged txids allowed - -> TxSubmissionMempoolReader txid tx idx m - -> TxSubmissionMempoolWriter txid tx idx m - -> NodeToNodeVersion - -> TxSubmissionServerPipelined txid tx m () -txSubmissionInbound tracer (NumTxIdsToAck maxUnacked) mpReader mpWriter _version = - TxSubmissionServerPipelined $ do -#ifdef TXSUBMISSION_DELAY - -- make the client linger before asking for tx's and expending - -- our resources as well, as he may disconnect for some reason - threadDelay (fromMaybe (-1) longWait) -#endif - continueWithStateM (serverIdle Zero) initialServerState - where - -- TODO #1656: replace these fixed limits by policies based on - -- SizeInBytes and delta-Q and the bandwidth/delay product. - -- These numbers are for demo purposes only, the throughput will be low. - maxTxIdsToRequest = 3 :: Word16 - maxTxToRequest = 2 :: Word16 - - TxSubmissionMempoolReader{mempoolGetSnapshot} = mpReader - - TxSubmissionMempoolWriter - { txId - , mempoolAddTxs - } = mpWriter - - serverIdle :: forall (n :: N). - Nat n - -> StatefulM (ServerState txid tx) n txid tx m - serverIdle n = StatefulM $ \st -> case n of - Zero -> do - if canRequestMoreTxs st - then do - -- There are no replies in flight, but we do know some more txs we - -- can ask for, so lets ask for them and more txids. - traceWith tracer (TraceTxInboundCanRequestMoreTxs (natToInt n)) - pure $ continueWithState (serverReqTxs Zero) st - - else do - traceWith tracer (TraceTxInboundCannotRequestMoreTxs (natToInt n)) - -- There's no replies in flight, and we have no more txs we can - -- ask for so the only remaining thing to do is to ask for more - -- txids. Since this is the only thing to do now, we make this a - -- blocking call. - let numTxIdsToRequest = maxTxIdsToRequest `min` maxUnacked - assert (requestedTxIdsInFlight st == 0 - && Seq.null (unacknowledgedTxIds st) - && Map.null (availableTxids st) - && Map.null (bufferedTxs st)) $ - pure $ - SendMsgRequestTxIdsBlocking - (NumTxIdsToAck (numTxsToAcknowledge st)) - (NumTxIdsToReq numTxIdsToRequest) - -- Our result if the client terminates the protocol - (traceWith tracer TraceTxInboundTerminated) - ( collectAndContinueWithState (handleReply Zero) st { - numTxsToAcknowledge = 0, - requestedTxIdsInFlight = numTxIdsToRequest - } - . CollectTxIds (NumTxIdsToReq numTxIdsToRequest) - . NonEmpty.toList) - - Succ n' -> if canRequestMoreTxs st - then do - -- We have replies in flight and we should eagerly collect them if - -- available, but there are transactions to request too so we - -- should not block waiting for replies. - -- - -- Having requested more transactions, we opportunistically ask - -- for more txids in a non-blocking way. This is how we pipeline - -- asking for both txs and txids. - -- - -- It's important not to pipeline more requests for txids when we - -- have no txs to ask for, since (with no other guard) this will - -- put us into a busy-polling loop. - -- - traceWith tracer (TraceTxInboundCanRequestMoreTxs (natToInt n)) - pure $ CollectPipelined - (Just (continueWithState (serverReqTxs (Succ n')) st)) - (collectAndContinueWithState (handleReply n') st) - - else do - traceWith tracer (TraceTxInboundCannotRequestMoreTxs (natToInt n)) - -- In this case there is nothing else to do so we block until we - -- collect a reply. - pure $ CollectPipelined - Nothing - (collectAndContinueWithState (handleReply n') st) - where - canRequestMoreTxs :: ServerState k tx -> Bool - canRequestMoreTxs st = - not (Map.null (availableTxids st)) - - handleReply :: forall (n :: N). - Nat n - -> StatefulCollect (ServerState txid tx) n txid tx m - handleReply n = StatefulCollect $ \st collect -> case collect of - CollectTxIds (NumTxIdsToReq reqNo) txids -> do - -- Check they didn't send more than we asked for. We don't need to - -- check for a minimum: the blocking case checks for non-zero - -- elsewhere, and for the non-blocking case it is quite normal for - -- them to send us none. - let txidsSeq = Seq.fromList (map fst txids) - txidsMap = Map.fromList txids - - unless (Seq.length txidsSeq <= fromIntegral reqNo) $ - throwIO ProtocolErrorTxIdsNotRequested - - -- Upon receiving a batch of new txids we extend our available set, - -- and extended the unacknowledged sequence. - -- - -- We also pre-emptively acknowledge those txids that are already in - -- the mempool. This prevents us from requesting their corresponding - -- transactions again in the future. - let st' = st { - requestedTxIdsInFlight = requestedTxIdsInFlight st - reqNo - } - mpSnapshot <- atomically mempoolGetSnapshot - continueWithStateM - (serverIdle n) - (acknowledgeTxIds st' txidsSeq txidsMap mpSnapshot) - - CollectTxs txids txs -> do - -- To start with we have to verify that the txs they have sent us do - -- correspond to the txs we asked for. This is slightly complicated by - -- the fact that in general we get a subset of the txs that we asked - -- for. We should never get a tx we did not ask for. We take a strict - -- approach to this and check it. - -- - let txsMap :: Map txid tx - txsMap = Map.fromList [ (txId tx, tx) | tx <- txs ] - - txidsReceived = Map.keysSet txsMap - txidsRequested = Set.fromList txids - - unless (txidsReceived `Set.isSubsetOf` txidsRequested) $ - throwIO ProtocolErrorTxNotRequested - - -- We can match up all the txids we requested, with those we - -- received. - let txIdsRequestedWithTxsReceived :: Map txid (Maybe tx) - txIdsRequestedWithTxsReceived = - Map.map Just txsMap - <> Map.fromSet (const Nothing) txidsRequested - - -- We still have to acknowledge the txids we were given. This - -- combined with the fact that we request txs out of order means - -- our bufferedTxs has to track all the txids we asked for, even - -- though not all have replies. - bufferedTxs1 = bufferedTxs st <> txIdsRequestedWithTxsReceived - - -- We have to update the unacknowledgedTxIds here eagerly and not - -- delay it to serverReqTxs, otherwise we could end up blocking in - -- serverIdle on more pipelined results rather than being able to - -- move on. - - -- Check if having received more txs we can now confirm any (in - -- strict order in the unacknowledgedTxIds sequence). - (acknowledgedTxIds, unacknowledgedTxIds') = - Seq.spanl (`Map.member` bufferedTxs1) (unacknowledgedTxIds st) - - -- If so we can submit the acknowledged txs to our local mempool - txsReady = foldr (\txid r -> maybe r (:r) (bufferedTxs1 Map.! txid)) - [] acknowledgedTxIds - - -- And remove acknowledged txs from our buffer - bufferedTxs2 = Foldable.foldl' (flip Map.delete) - bufferedTxs1 acknowledgedTxIds - - -- If we are acknowledging transactions that are still in - -- unacknowledgedTxIds' we need to re-add them so that we also can - -- acknowledge them again later. This will happen in case of - -- duplicate txids within the same window. - live = filter (`elem` unacknowledgedTxIds') $ toList acknowledgedTxIds - bufferedTxs3 = forceElemsToWHNF $ bufferedTxs2 <> - Map.fromList (zip live (repeat Nothing)) - - let !collected = length txs - traceWith tracer $ - TraceTxSubmissionCollected collected - - txidsAccepted <- mempoolAddTxs txsReady - - let !accepted = length txidsAccepted - - traceWith tracer $ TraceTxSubmissionProcessed ProcessedTxCount { - ptxcAccepted = accepted - , ptxcRejected = collected - accepted - } - - continueWithStateM (serverIdle n) st { - bufferedTxs = bufferedTxs3, - unacknowledgedTxIds = unacknowledgedTxIds', - numTxsToAcknowledge = numTxsToAcknowledge st - + fromIntegral (Seq.length acknowledgedTxIds) - } - - -- Pre-emptively acknowledge those of the available transaction IDs that - -- are already in the mempool and return the updated 'ServerState'. - -- - -- This enables us to effectively filter out transactions that we don't - -- need to bother requesting from the client since they're already in the - -- mempool. - -- - acknowledgeTxIds :: ServerState txid tx - -> StrictSeq txid - -> Map txid SizeInBytes - -> MempoolSnapshot txid tx idx - -> ServerState txid tx - acknowledgeTxIds st txidsSeq _ _ | Seq.null txidsSeq = st - acknowledgeTxIds st txidsSeq txidsMap MempoolSnapshot{mempoolHasTx} = - -- Return the next 'ServerState' - st { - availableTxids = availableTxids', - bufferedTxs = bufferedTxs'', - unacknowledgedTxIds = unacknowledgedTxIds'', - numTxsToAcknowledge = numTxsToAcknowledge st - + fromIntegral (Seq.length acknowledgedTxIds) - } - where - - -- Divide the new txids in two: those that are already in the - -- mempool or in flight and those that are not. We'll request some txs from the - -- latter. - (ignoredTxids, availableTxidsMp) = - Map.partitionWithKey - (\txid _ -> mempoolHasTx txid) - txidsMap - - availableTxidsU = - Map.filterWithKey - (\txid _ -> notElem txid (unacknowledgedTxIds st)) - txidsMap - - availableTxids' = availableTxids st <> Map.intersection availableTxidsMp availableTxidsU - - -- The txs that we intentionally don't request, because they are - -- already in the mempool, need to be acknowledged. - -- - -- So we extend bufferedTxs with those txs (so of course they have - -- no corresponding reply). - bufferedTxs' = bufferedTxs st - <> Map.map (const Nothing) ignoredTxids - - unacknowledgedTxIds' = unacknowledgedTxIds st <> txidsSeq - - -- Check if having decided not to request more txs we can now - -- confirm any txids (in strict order in the unacknowledgedTxIds - -- sequence). This is used in the 'numTxsToAcknowledge' below - -- which will then be used next time we SendMsgRequestTxIds. - -- - (acknowledgedTxIds, unacknowledgedTxIds'') = - Seq.spanl (`Map.member` bufferedTxs') unacknowledgedTxIds' - - - -- If so we can remove acknowledged txs from our buffer provided that they - -- are not still in unacknowledgedTxIds''. This happens in case of duplicate - -- txids. - bufferedTxs'' = forceElemsToWHNF $ Foldable.foldl' (\m txid -> if elem txid unacknowledgedTxIds'' - then m - else Map.delete txid m) - bufferedTxs' acknowledgedTxIds - - serverReqTxs :: forall (n :: N). - Nat n - -> Stateful (ServerState txid tx) n txid tx m - serverReqTxs n = Stateful $ \st -> do - -- TODO: This implementation is deliberately naive, we pick in an - -- arbitrary order and up to a fixed limit. This is to illustrate - -- that we can request txs out of order. In the final version we will - -- try to pick in-order and only pick out of order when we have to. - -- We will also uses the size of txs in bytes as our limit for - -- upper and lower watermarks for pipelining. We'll also use the - -- amount in flight and delta-Q to estimate when we're in danger of - -- becoming idle, and need to request stalled txs. - -- - let (txsToRequest, availableTxids') = - Map.splitAt (fromIntegral maxTxToRequest) (availableTxids st) - - SendMsgRequestTxsPipelined - (Map.keys txsToRequest) - (continueWithStateM (serverReqTxIds (Succ n)) st { - availableTxids = availableTxids' - }) - - serverReqTxIds :: forall (n :: N). - Nat n - -> StatefulM (ServerState txid tx) n txid tx m - serverReqTxIds n = StatefulM $ \st -> do - -- This definition is justified by the fact that the - -- 'numTxsToAcknowledge' are not included in the - -- 'unacknowledgedTxIds'. - let numTxIdsToRequest = - (maxUnacked - - fromIntegral (Seq.length (unacknowledgedTxIds st)) - - requestedTxIdsInFlight st) - `min` maxTxIdsToRequest - - if numTxIdsToRequest > 0 - then pure $ SendMsgRequestTxIdsPipelined - (NumTxIdsToAck (numTxsToAcknowledge st)) - (NumTxIdsToReq numTxIdsToRequest) - (continueWithStateM (serverIdle (Succ n)) st { - requestedTxIdsInFlight = requestedTxIdsInFlight st - + numTxIdsToRequest, - numTxsToAcknowledge = 0 - }) - else continueWithStateM (serverIdle n) st - -newtype Stateful s n txid tx m = Stateful (s -> ServerStIdle n txid tx m ()) - -newtype StatefulM s n txid tx m - = StatefulM (s -> m (ServerStIdle n txid tx m ())) - -newtype StatefulCollect s n txid tx m - = StatefulCollect (s -> Collect txid tx -> m (ServerStIdle n txid tx m ())) - --- | After checking that there are no unexpected thunks in the provided state, --- pass it to the provided function. --- --- See 'checkInvariant' and 'unsafeNoThunks'. -continueWithState :: NoThunks s - => Stateful s n txid tx m - -> s - -> ServerStIdle n txid tx m () -continueWithState (Stateful f) !st = - checkInvariant (show <$> unsafeNoThunks st) (f st) - --- | A variant of 'continueWithState' to be more easily utilized with --- 'serverIdle' and 'serverReqTxIds'. -continueWithStateM :: NoThunks s - => StatefulM s n txid tx m - -> s - -> m (ServerStIdle n txid tx m ()) -continueWithStateM (StatefulM f) !st = - checkInvariant (show <$> unsafeNoThunks st) (f st) -{-# NOINLINE continueWithStateM #-} - --- | A variant of 'continueWithState' to be more easily utilized with --- 'handleReply'. -collectAndContinueWithState :: NoThunks s - => StatefulCollect s n txid tx m - -> s - -> Collect txid tx - -> m (ServerStIdle n txid tx m ()) -collectAndContinueWithState (StatefulCollect f) !st c = - checkInvariant (show <$> unsafeNoThunks st) (f st c) -{-# NOINLINE collectAndContinueWithState #-} From f7850ac678474b9ea63a259b0b7bcead8ab6081d Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 14 Oct 2025 17:54:52 +0200 Subject: [PATCH 24/24] dmq-tests: increased heap limit --- nix/ouroboros-network.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/ouroboros-network.nix b/nix/ouroboros-network.nix index df42808d581..c819a4d09d0 100644 --- a/nix/ouroboros-network.nix +++ b/nix/ouroboros-network.nix @@ -114,7 +114,7 @@ let packages.ouroboros-network.components.tests.ouroboros-network-sim-tests.doCheck = onLinux; packages.dmq-node.components.tests.dmq-tests.preCheck = - if buildSystem == "x86_64-linux" then "export GHCRTS=-M1600M" else ""; + if buildSystem == "x86_64-linux" then "export GHCRTS=-M2500M" else ""; packages.network-mux.components.tests.test.preCheck = if buildSystem == "x86_64-linux" then "export GHCRTS=-M800M" else ""; packages.ouroboros-network.components.tests.protocols-test.preCheck =