Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}

module Cardano.Network.NodeToClient.Version
( NodeToClientVersion (..)
Expand All @@ -21,6 +22,7 @@ import Ouroboros.Network.CodecCBORTerm
import Ouroboros.Network.Handshake.Acceptable (Accept (..), Acceptable (..))
import Ouroboros.Network.Handshake.Queryable (Queryable (..))
import Ouroboros.Network.Magic
import Ouroboros.Network.Util (PrettyShow (..))


-- | Enumeration of node to client protocol versions.
Expand Down Expand Up @@ -68,7 +70,8 @@ data NodeToClientVersion
| NodeToClientV_23
-- ^ added @QueryDRepsDelegations@,
-- LedgerPeerSnapshot CBOR encoding contains block hash and NetworkMagic
deriving (Eq, Ord, Enum, Bounded, Show, Generic, NFData)
deriving stock (Eq, Ord, Enum, Bounded, Show, Generic)
deriving anyclass (NFData, PrettyShow)

-- | We set 16ths bit to distinguish `NodeToNodeVersion` and
-- `NodeToClientVersion`. This way connecting wrong protocol suite will fail
Expand Down Expand Up @@ -127,7 +130,8 @@ data NodeToClientVersionData = NodeToClientVersionData
{ networkMagic :: !NetworkMagic
, query :: !Bool
}
deriving (Eq, Show, Generic, NFData)
deriving stock (Eq, Show, Generic)
deriving anyclass (NFData, PrettyShow)

instance Acceptable NodeToClientVersionData where
acceptableVersion local remote
Expand Down
16 changes: 10 additions & 6 deletions cardano-diffusion/api/lib/Cardano/Network/NodeToNode/Version.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}

module Cardano.Network.NodeToNode.Version
( NodeToNodeVersion (..)
Expand Down Expand Up @@ -35,6 +36,7 @@ import Ouroboros.Network.Handshake.Queryable (Queryable (..))
import Ouroboros.Network.Magic
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.PerasSupport
import Ouroboros.Network.Util (PrettyShow (..))

-- | Enumeration of node to node protocol versions.
--
Expand Down Expand Up @@ -88,7 +90,8 @@ data NodeToNodeVersion =
-- ^ Experimental.
--
-- Adds support for Peras mini-protocols (if 'PerasFlag' is set).
deriving (Eq, Ord, Enum, Bounded, Show, Generic, NFData, NoThunks)
deriving stock (Eq, Ord, Enum, Bounded, Show, Generic)
deriving anyclass (NFData, NoThunks, PrettyShow)

nodeToNodeVersionCodec :: CodecCBORTerm (Text, Maybe Int) NodeToNodeVersion
nodeToNodeVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
Expand Down Expand Up @@ -117,9 +120,10 @@ data NodeToNodeVersionData = NodeToNodeVersionData
, query :: !Bool
, perasSupport :: !PerasSupport
}
deriving (Show, Eq, Generic, NFData)
deriving stock (Show, Eq, Generic)
-- 'Eq' instance is not provided, it is not what we need in version
-- negotiation (see 'Acceptable' instance below).
deriving anyclass (NFData, PrettyShow)

instance Acceptable NodeToNodeVersionData where
-- | Check that both side use the same 'networkMagic'. Choose smaller one
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Non-Breaking

- Exported `PraosFetchMode` from `Cardano.Network.LedgerPeerConsensusInterface`
- Added `PrettyShow` instances for
- `NodeToNodeVersion`
- `NodeToNodeVersionData`
- `NodeToClientVersion`
- `NodeToClientVersionData`
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Cardano.Network.LedgerPeerConsensusInterface
, GetImmutableBlockPointError (..)
-- * Re-exports
, FetchMode (..)
, PraosFetchMode (..)
, LedgerStateJudgement (..)
, OutboundConnectionsState (..)
) where
Expand All @@ -15,7 +16,7 @@ import Cardano.Network.LedgerStateJudgement
import Cardano.Network.PeerSelection.LocalRootPeers
(OutboundConnectionsState (..))
import Ouroboros.Network.Block (Point)
import Ouroboros.Network.BlockFetch.ConsensusInterface (FetchMode (..))
import Ouroboros.Network.BlockFetch.ConsensusInterface (FetchMode (..), PraosFetchMode (..))
import Ouroboros.Network.PeerSelection.LedgerPeers.Type (RawBlockHash)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
For top level release notes, leave all the headers commented out.
-->

<!--
### Breaking

- A bullet item for the Breaking category.

-->

### Non-Breaking

- Expose `runClientBurst`, `runServerBurst` and `runCBORDecoderWithChannel` from
`ReqResp` for use in the incremental decoder benchmark.
- Expose `ReqResp` in new tests-lib library.


<!--
### Patch

- A bullet item for the Patch category.

-->
45 changes: 26 additions & 19 deletions network-mux/network-mux.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ flag tracetcpinfo
manual: True
default: False

common demo-deps
common lib-defaults
default-language: Haskell2010
default-extensions: ImportQualifiedPost
ghc-options:
-threaded
-Wall
-fno-ignore-asserts
-Wno-unticked-promoted-constructors
-Wcompat
-Wincomplete-uni-patterns
-Wincomplete-record-updates
Expand All @@ -48,7 +47,14 @@ common demo-deps
ghc-options:
-Wno-pattern-namespace-specifier

common demo-deps
import: lib-defaults
ghc-options:
-threaded
-fno-ignore-asserts

library
import: lib-defaults
build-depends:
-- The Windows version of network-3.1.2 is missing
-- functions, see
Expand Down Expand Up @@ -105,23 +111,24 @@ library
if os(windows)
exposed-modules:
Network.Mux.Bearer.NamedPipe
default-language: Haskell2010
default-extensions: ImportQualifiedPost
ghc-options:
-Wall
-Wcompat
-Widentities
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wno-unticked-promoted-constructors
-Wpartial-fields
-Wredundant-constraints
-Wunused-packages

-- In ghc-9.14 the `pattern` namespace specifier is deprecated.
if impl(ghc >=9.14)
ghc-options:
-Wno-pattern-namespace-specifier
library tests-lib
import: lib-defaults
visibility: public
hs-source-dirs: test
exposed-modules:
Test.Mux.ReqResp

build-depends:
base >=4.14 && <4.23,
binary,
bytestring >=0.10 && <0.13,
cborg >=0.2.8 && <0.3,
contra-tracer >=0.1 && <0.3,
io-classes ^>=1.8,
network-mux,
primitive,
serialise,

test-suite test
type: exitcode-stdio-1.0
Expand Down
3 changes: 3 additions & 0 deletions network-mux/test/Test/Mux/ReqResp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ module Test.Mux.ReqResp
, ReqRespClientLoop (..)
, runClientBurstCBOR
, runClientBurstBin
, runClientBurst
-- ** Active Server
, ReqRespServerBurst (..)
, ReqRespServerLoop (..)
, runServerBurstCBOR
, runServerBurstBin
, runServerBurst
, runCBORDecoderWithChannel
) where

import Codec.CBOR.Decoding qualified as CBOR hiding (Done, Fail)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Non-Breaking

- Added `JSONField` instance for `NoExtraFlags`
2 changes: 2 additions & 0 deletions ouroboros-network/lib/Ouroboros/Network/KeepAlive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Ouroboros.Network.KeepAlive
, keepAliveClient
, keepAliveServer
, TraceKeepAliveClient (..)
, module Registry
) where

import Control.Concurrent.Class.MonadSTM qualified as Lazy
Expand All @@ -21,6 +22,7 @@ import Data.Map.Strict qualified as M
import Data.Maybe (fromJust)
import System.Random (StdGen, random)

import Ouroboros.Network.KeepAlive.Registry as Registry
import Ouroboros.Network.ControlMessage (ControlMessage (..), ControlMessageSTM)
import Ouroboros.Network.DeltaQ
import Ouroboros.Network.Protocol.KeepAlive.Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import Ouroboros.Network.DeltaQ (GSV (GSV),
import Ouroboros.Network.Diffusion.Topology (LocalRootPeersGroup (..),
LocalRootPeersGroups (..), LocalRoots (..), NetworkTopology (..),
PublicRootPeers (..), RootConfig (..))
import Ouroboros.Network.Diffusion.Types (DiffusionTracer (..))
import Ouroboros.Network.Diffusion.Types (DiffusionTracer (..), NoExtraFlags)
import Ouroboros.Network.DiffusionMode
import Ouroboros.Network.Driver.Simple
import Ouroboros.Network.ExitPolicy (RepromoteDelay (repromoteDelay))
Expand Down Expand Up @@ -454,6 +454,9 @@ instance ToJSON addr => ToJSON (PeerSharingResult addr) where
class JSONField extraFlags where
fieldName :: Proxy extraFlags -> Maybe Key

instance JSONField NoExtraFlags where
fieldName _ = Nothing

instance (JSONField extraFlags, ToJSON extraFlags) => ToJSON (LocalRootConfig extraFlags) where
toJSON LocalRootConfig { peerAdvertise,
extraLocalRootFlags,
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-network/ouroboros-network.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ library
Ouroboros.Network.Diffusion.Utils
Ouroboros.Network.ExitPolicy
Ouroboros.Network.KeepAlive
Ouroboros.Network.KeepAlive.Registry
Ouroboros.Network.PeerSelection
Ouroboros.Network.PeerSelection.Churn
Ouroboros.Network.PeerSelection.Governor
Expand Down Expand Up @@ -267,6 +266,7 @@ library
Ouroboros.Network.TxSubmission.Outbound

other-modules:
Ouroboros.Network.KeepAlive.Registry
Ouroboros.Network.PeerSelection.Governor.BigLedgerPeers
Ouroboros.Network.PeerSelection.Governor.EstablishedPeers
Ouroboros.Network.PeerSelection.Governor.KnownPeers
Expand Down