Skip to content

Commit

Permalink
Merge #3374
Browse files Browse the repository at this point in the history
3374: CAD-3444 typed-protocols changes from p2p-master r=coot a=coot

- typed-protocols: added TokPeerRole
- typed-protocols: Codecs
- typed-protocols-cborg: CBOR codecs for typed-protocols
- typed-protocols-examples: added CBOR codecs
- typed-protocols: udpated upstream dependencies


Co-authored-by: Marcin Szamotulski <[email protected]>
  • Loading branch information
iohk-bors[bot] and coot authored Oct 15, 2021
2 parents a6f90a7 + 89d5509 commit e8875cf
Show file tree
Hide file tree
Showing 54 changed files with 246 additions and 235 deletions.
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
index-state: 2021-02-15T00:00:00Z

packages: ./typed-protocols
./typed-protocols-cborg
./typed-protocols-examples
./ouroboros-network-testing
./monoidal-synchronisation
Expand Down
1 change: 1 addition & 0 deletions ouroboros-consensus-test/ouroboros-consensus-test.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ library
, tasty
, tasty-golden
, tasty-quickcheck
, typed-protocols
, template-haskell
, text >=1.2 && <1.3
, time
Expand Down
7 changes: 4 additions & 3 deletions ouroboros-consensus-test/src/Test/ThreadNet/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ import Data.Void (Void)
import GHC.Stack
import System.Random (mkStdGen)

import Network.TypedProtocol.Codec (AnyMessage (..), CodecFailure,
mapFailureCodec)
import qualified Network.TypedProtocol.Codec as Codec

import qualified Ouroboros.Network.AnchoredFragment as AF
import Ouroboros.Network.BlockFetch (BlockFetchConfiguration (..),
TraceLabelPeer (..))
import Ouroboros.Network.Channel
import Ouroboros.Network.Codec (AnyMessage (..), CodecFailure,
mapFailureCodec)
import qualified Ouroboros.Network.Codec as Codec
import Ouroboros.Network.MockChain.Chain (Chain (Genesis))
import Ouroboros.Network.Point (WithOrigin (..))
import qualified Ouroboros.Network.Protocol.ChainSync.Type as CS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ module Ouroboros.Consensus.Network.NodeToClient (

import Codec.CBOR.Decoding (Decoder)
import Codec.CBOR.Encoding (Encoding)
import Codec.CBOR.Read (DeserialiseFailure)
import Codec.Serialise (Serialise)

import Control.Tracer
import Data.ByteString.Lazy (ByteString)
import Data.Void (Void)

import Network.TypedProtocol.Codec

import qualified Ouroboros.Network.AnchoredFragment as AF
import Ouroboros.Network.Block (Serialised, decodePoint, decodeTip,
encodePoint, encodeTip)
import Ouroboros.Network.BlockFetch
import Ouroboros.Network.Channel
import Ouroboros.Network.Codec
import Ouroboros.Network.Driver
import Ouroboros.Network.Mux
import Ouroboros.Network.NodeToClient hiding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Ouroboros.Consensus.Network.NodeToNode (

import Codec.CBOR.Decoding (Decoder)
import Codec.CBOR.Encoding (Encoding)
import Codec.CBOR.Read (DeserialiseFailure)
import Control.Monad (forever)
import Control.Monad.Class.MonadTime (MonadTime)
import Control.Monad.Class.MonadTimer (MonadTimer)
Expand All @@ -42,14 +43,15 @@ import Data.ByteString.Lazy (ByteString)
import Data.Map.Strict (Map)
import Data.Void (Void)

import Network.TypedProtocol.Codec

import Ouroboros.Network.AnchoredFragment (AnchoredFragment)
import Ouroboros.Network.Block (Serialised (..), decodePoint,
decodeTip, encodePoint, encodeTip)
import Ouroboros.Network.BlockFetch
import Ouroboros.Network.BlockFetch.Client (BlockFetchClient,
blockFetchClient)
import Ouroboros.Network.Channel
import Ouroboros.Network.Codec
import Ouroboros.Network.DeltaQ
import Ouroboros.Network.Driver
import Ouroboros.Network.KeepAlive
Expand Down
15 changes: 4 additions & 11 deletions ouroboros-network-framework/ouroboros-network-framework.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ build-type: Simple
extra-source-files: CHANGELOG.md

library
exposed-modules: Ouroboros.Network.Codec
Ouroboros.Network.CodecCBORTerm
exposed-modules: Ouroboros.Network.CodecCBORTerm
Ouroboros.Network.Channel
Ouroboros.Network.Driver
Ouroboros.Network.Driver.Simple
Expand Down Expand Up @@ -81,11 +80,9 @@ library
, network >=3.1.2 && < 3.2
, network-mux >=0.1 && < 0.2
, typed-protocols >=0.1 && < 0.2
, typed-protocols-cborg >=0.1 && < 0.2
, Win32-network >=0.1 && < 0.2

-- Remove once codec is defined locally
, typed-protocols-examples

if os(windows)
build-depends: Win32 >= 2.5.4.1 && <3.0

Expand All @@ -104,11 +101,7 @@ test-suite test
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs: test
other-modules: Network.TypedProtocol.PingPong.Codec.CBOR
Network.TypedProtocol.ReqResp.Codec.CBOR
Test.Network.TypedProtocol.PingPong.Codec
Test.Network.TypedProtocol.ReqResp.Codec
Test.Ouroboros.Network.Driver
other-modules: Test.Ouroboros.Network.Driver
Test.Ouroboros.Network.Orphans
Test.Ouroboros.Network.Socket
Test.Ouroboros.Network.Subscription
Expand Down Expand Up @@ -136,6 +129,7 @@ test-suite test
, network-mux
, ouroboros-network-framework
, typed-protocols
, typed-protocols-cborg
, typed-protocols-examples

if os(windows)
Expand All @@ -156,7 +150,6 @@ test-suite test

executable demo-ping-pong
hs-source-dirs: demo test
other-modules: Network.TypedProtocol.PingPong.Codec.CBOR
main-is: ping-pong.hs
build-depends: base,
async,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ import Control.Tracer (Tracer (..), traceWith)

import Network.Mux.Timeout
import Network.TypedProtocol.Core
import Network.TypedProtocol.Codec
import Network.TypedProtocol.Pipelined
import Network.TypedProtocol.Driver

import Ouroboros.Network.Codec
import Ouroboros.Network.Channel
import Ouroboros.Network.Driver.Simple (TraceSendRecv(..), DecoderFailure (..))
import Ouroboros.Network.Util.ShowProxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ module Ouroboros.Network.Driver.Simple (
) where

import Network.TypedProtocol.Core
import Network.TypedProtocol.Codec
import Network.TypedProtocol.Pipelined
import Network.TypedProtocol.Driver

import Ouroboros.Network.Util.ShowProxy

import Ouroboros.Network.Channel
import Ouroboros.Network.Codec

import Control.Monad.Class.MonadSTM
import Control.Monad.Class.MonadAsync
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-network-framework/src/Ouroboros/Network/Mux.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Data.Void (Void)
import qualified Data.ByteString.Lazy as LBS

import Network.TypedProtocol.Core
import Network.TypedProtocol.Codec
import Network.TypedProtocol.Pipelined

import qualified Network.Mux.Compat as Mux
Expand All @@ -50,7 +51,6 @@ import Network.Mux

import Ouroboros.Network.Channel
import Ouroboros.Network.ConnectionId
import Ouroboros.Network.Codec
import Ouroboros.Network.Driver
import Ouroboros.Network.Util.ShowProxy (ShowProxy)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ import qualified Data.Map as Map
import Data.Maybe (mapMaybe)
import Text.Printf

import Network.TypedProtocol.Codec.CBOR

import qualified Codec.CBOR.Encoding as CBOR
import qualified Codec.CBOR.Decoding as CBOR
import qualified Codec.CBOR.Read as CBOR
import qualified Codec.CBOR.Term as CBOR

import Ouroboros.Network.Codec
import Ouroboros.Network.CodecCBORTerm
import Ouroboros.Network.Driver.Limits

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import Data.Text (Text)
import qualified Data.Text as T
import Data.ByteString.Lazy (ByteString)

import Ouroboros.Network.Codec
import Ouroboros.Network.CodecCBORTerm
import Network.TypedProtocol.Codec

import Ouroboros.Network.CodecCBORTerm
import Ouroboros.Network.Protocol.Handshake.Codec
import Ouroboros.Network.Protocol.Handshake.Type
import Ouroboros.Network.Protocol.Handshake.Version
Expand Down
4 changes: 2 additions & 2 deletions ouroboros-network-framework/src/Ouroboros/Network/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ import qualified Network.Socket as Socket
import Control.Tracer

import qualified Network.Mux.Compat as Mx
import Network.Mux.DeltaQ.TraceTransformer
import Network.Mux.DeltaQ.TraceTransformer
import Network.TypedProtocol.Codec hiding (encode, decode)

import Ouroboros.Network.ConnectionId
import Ouroboros.Network.Codec hiding (encode, decode)
import Ouroboros.Network.Driver.Limits
import Ouroboros.Network.Mux
import Ouroboros.Network.ErrorPolicy
Expand Down
6 changes: 1 addition & 5 deletions ouroboros-network-framework/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module Main (main) where

import Test.Tasty

import qualified Test.Network.TypedProtocol.PingPong.Codec as PingPong
import qualified Test.Network.TypedProtocol.ReqResp.Codec as ReqResp
import qualified Test.Ouroboros.Network.Driver as Driver
import qualified Test.Ouroboros.Network.Socket as Socket
import qualified Test.Ouroboros.Network.Subscription as Subscription
Expand All @@ -15,9 +13,7 @@ main = defaultMain tests
tests :: TestTree
tests =
testGroup "ouroboros-network-framework"
[ PingPong.tests
, ReqResp.tests
, Driver.tests
[ Driver.tests
, Socket.tests
, Subscription.tests
, RateLimiting.tests
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit e8875cf

Please sign in to comment.