Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of NonP2P Network Components #5007

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
11 changes: 11 additions & 0 deletions ouroboros-network-framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
### 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`.

### Non-breaking changes

Expand Down
2 changes: 1 addition & 1 deletion ouroboros-network-framework/demo/connection-manager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ import Ouroboros.Network.Protocol.Handshake.Unversioned
import Ouroboros.Network.Protocol.Handshake.Version (Acceptable (..),
Queryable (..))
import Ouroboros.Network.RethrowPolicy
import Ouroboros.Network.Server qualified as Server
import Ouroboros.Network.Server.RateLimiting (AcceptedConnectionsLimit (..))
import Ouroboros.Network.Server2 qualified as Server
import Ouroboros.Network.Snocket (Snocket, socketSnocket)
import Ouroboros.Network.Snocket qualified as Snocket
import Ouroboros.Network.Util.ShowProxy
Expand Down
49 changes: 22 additions & 27 deletions ouroboros-network-framework/demo/ping-pong.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ import Text.Printf (printf)

import Network.Mux qualified as Mx

import Ouroboros.Network.ErrorPolicy
import Ouroboros.Network.IOManager
import Ouroboros.Network.Mux
import Ouroboros.Network.Snocket
import Ouroboros.Network.Snocket qualified as Snocket
import Ouroboros.Network.Socket
import Ouroboros.Network.Util.ShowProxy (ShowProxy (..))

import Ouroboros.Network.Protocol.Handshake (HandshakeArguments (..))
import Ouroboros.Network.Protocol.Handshake.Codec
import Ouroboros.Network.Protocol.Handshake.Unversioned
import Ouroboros.Network.Protocol.Handshake.Version
import Ouroboros.Network.Server.Simple qualified as Server

import Network.TypedProtocol.PingPong.Client as PingPong
import Network.TypedProtocol.PingPong.Codec.CBOR as PingPong
Expand Down Expand Up @@ -157,24 +158,21 @@ clientPingPong pipelined =
serverPingPong :: IO Void
serverPingPong =
withIOManager $ \iomgr -> do
networkState <- newNetworkMutableState
_ <- async $ cleanNetworkMutableState networkState
withServerNode
Server.with
(Snocket.localSnocket iomgr)
makeLocalBearer
mempty
nullNetworkServerTracers
networkState
(AcceptedConnectionsLimit maxBound maxBound 0)
defaultLocalSocketAddr
unversionedHandshakeCodec
noTimeLimitsHandshake
unversionedProtocolDataCodec
(HandshakeCallbacks acceptableVersion queryVersion)
HandshakeArguments {
haHandshakeTracer = nullTracer,
haHandshakeCodec = unversionedHandshakeCodec,
haVersionDataCodec = unversionedProtocolDataCodec,
haAcceptVersion = acceptableVersion,
haQueryVersion = queryVersion,
haTimeLimits = noTimeLimitsHandshake
}
(unversionedProtocol (SomeResponderApplication app))
nullErrorPolicies
$ \_ serverAsync ->
wait serverAsync -- block until async exception
$ \_ serverAsync -> wait serverAsync -- block until server finishes
where
app :: OuroborosApplicationWithMinimalCtx
Mx.ResponderMode LocalAddress LBS.ByteString IO Void ()
Expand Down Expand Up @@ -254,24 +252,21 @@ clientPingPong2 =
serverPingPong2 :: IO Void
serverPingPong2 =
withIOManager $ \iomgr -> do
networkState <- newNetworkMutableState
_ <- async $ cleanNetworkMutableState networkState
withServerNode
Server.with
(Snocket.localSnocket iomgr)
makeLocalBearer
mempty
nullNetworkServerTracers
networkState
(AcceptedConnectionsLimit maxBound maxBound 0)
defaultLocalSocketAddr
unversionedHandshakeCodec
noTimeLimitsHandshake
unversionedProtocolDataCodec
(HandshakeCallbacks acceptableVersion queryVersion)
HandshakeArguments {
haHandshakeTracer = nullTracer,
haHandshakeCodec = unversionedHandshakeCodec,
haVersionDataCodec = unversionedProtocolDataCodec,
haAcceptVersion = acceptableVersion,
haQueryVersion = queryVersion,
haTimeLimits = noTimeLimitsHandshake
}
(unversionedProtocol (SomeResponderApplication app))
nullErrorPolicies
$ \_ serverAsync ->
wait serverAsync -- block until async exception
$ \_ serverAsync -> wait serverAsync -- block until async exception
where
app :: OuroborosApplicationWithMinimalCtx
Mx.ResponderMode addr LBS.ByteString IO Void ()
Expand Down
8 changes: 3 additions & 5 deletions ouroboros-network-framework/io-tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import Test.Tasty

import Test.Ouroboros.Network.Driver qualified as Driver
import Test.Ouroboros.Network.RawBearer qualified as RawBearer
import Test.Ouroboros.Network.Server2.IO qualified as Server2
import Test.Ouroboros.Network.Server.IO qualified as Server
import Test.Ouroboros.Network.Socket qualified as Socket
import Test.Ouroboros.Network.Subscription qualified as Subscription

main :: IO ()
main = withUtf8 $ defaultMain tests

tests :: TestTree
tests =
testGroup "ouroboros-network-framework:io-tests" $
testGroup "ouroboros-network-framework:io-tests"
[ Driver.tests
, Server2.tests
, Server.tests
, Socket.tests
, Subscription.tests
, RawBearer.tests
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{-# OPTIONS_GHC -Wno-x-partial #-}
#endif

module Test.Ouroboros.Network.Server2.IO (tests) where
module Test.Ouroboros.Network.Server.IO (tests) where

import Control.Monad.Class.MonadThrow
import System.Random (mkStdGen)
Expand All @@ -34,7 +34,7 @@ import Test.Ouroboros.Network.Orphans ()
tests :: TestTree
tests =
testGroup "Ouroboros.Network"
[ testGroup "Server2"
[ testGroup "Server"
[ testProperty "unidirectional IO" prop_unidirectional_IO
, testProperty "bidirectional IO" prop_bidirectional_IO
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,19 @@ import Network.TypedProtocol.ReqResp.Type qualified as ReqResp

import Ouroboros.Network.Context
import Ouroboros.Network.Driver
import Ouroboros.Network.ErrorPolicy
import Ouroboros.Network.IOManager
import Ouroboros.Network.Snocket
import Ouroboros.Network.Socket
-- TODO: remove Mx prefixes
import Ouroboros.Network.Mux
import Ouroboros.Network.Server.Simple qualified as Server.Simple

import Network.Mux qualified as Mx
import Network.Mux.Bearer qualified as Mx
import Network.Mux.Timeout qualified as Mx
import Network.Mux.Types qualified as Mx

import Ouroboros.Network.Protocol.Handshake
import Ouroboros.Network.Protocol.Handshake.Codec
import Ouroboros.Network.Protocol.Handshake.Unversioned
import Ouroboros.Network.Protocol.Handshake.Version
Expand Down Expand Up @@ -197,7 +198,6 @@ prop_socket_send_recv initiatorAddr responderAddr configureSock f xs =

cv <- newEmptyTMVarIO
sv <- newEmptyTMVarIO
networkState <- newNetworkMutableState

{- The siblingVar is used by the initiator and responder to wait on each other before exiting.
- Without this wait there is a risk that one side will finish first causing the Muxbearer to
Expand Down Expand Up @@ -239,20 +239,21 @@ prop_socket_send_recv initiatorAddr responderAddr configureSock f xs =

let snocket = socketSnocket iomgr
res <-
withServerNode
Server.Simple.with
snocket
Mx.makeSocketBearer
((. Just) <$> configureSock)
networkTracers
networkState
(AcceptedConnectionsLimit maxBound maxBound 0)
responderAddr
unversionedHandshakeCodec
noTimeLimitsHandshake
unversionedProtocolDataCodec
(HandshakeCallbacks acceptableVersion queryVersion)
HandshakeArguments {
haHandshakeTracer = nullTracer,
haHandshakeCodec = unversionedHandshakeCodec,
haVersionDataCodec = unversionedProtocolDataCodec,
haAcceptVersion = acceptableVersion,
haQueryVersion = queryVersion,
haTimeLimits = noTimeLimitsHandshake

}
(unversionedProtocol (SomeResponderApplication responderApp))
nullErrorPolicies
$ \_ _ -> do
void $ connectToNode
snocket
Expand All @@ -273,14 +274,6 @@ prop_socket_send_recv initiatorAddr responderAddr configureSock f xs =
return (res == mapAccumL f 0 xs)

where
networkTracers = NetworkServerTracers {
nstMuxTracer = activeMuxTracer,
nstHandshakeTracer = nullTracer,
nstErrorPolicyTracer = showTracing stdoutTracer,
nstAcceptPolicyTracer = nullTracer
}


waitSibling :: StrictTVar IO Int -> IO ()
waitSibling cntVar = do
atomically $ modifyTVar cntVar (\a -> a - 1)
Expand Down
29 changes: 4 additions & 25 deletions ouroboros-network-framework/ouroboros-network-framework.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ library
Ouroboros.Network.Driver.Limits
Ouroboros.Network.Driver.Simple
Ouroboros.Network.Driver.Stateful
Ouroboros.Network.ErrorPolicy
Ouroboros.Network.IOManager
Ouroboros.Network.InboundGovernor
Ouroboros.Network.InboundGovernor.Event
Expand All @@ -55,39 +54,27 @@ library
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.Socket
Ouroboros.Network.Server2
Ouroboros.Network.Server.Simple
Ouroboros.Network.Snocket
Ouroboros.Network.Socket
Ouroboros.Network.Subscription
Ouroboros.Network.Subscription.Client
Ouroboros.Network.Subscription.Dns
Ouroboros.Network.Subscription.Ip
Ouroboros.Network.Subscription.PeerState
Ouroboros.Network.Subscription.Subscriber
Ouroboros.Network.Subscription.Worker
Simulation.Network.Snocket

-- other-extensions:
build-depends:
-- ^ only to derive nothunk instances
Win32-network ^>=0.2,
async >=2.1 && <2.3,
base >=4.12 && <4.21,
bytestring >=0.10 && <0.13,
cardano-prelude,
cborg >=0.2.1 && <0.3,
containers >=0.5 && <0.8,
contra-tracer,
deepseq,
dns <4.3,
hashable,
io-classes ^>=1.5.0,
iproute >=1.7 && <1.8,
monoidal-synchronisation ^>=0.1.0.6,
mtl,
network ^>=3.2.7,
network-mux ^>=0.6,
nothunks,
Expand All @@ -98,7 +85,6 @@ library
quiet,
random,
si-timers,
stm,
strict-stm,
text,
typed-protocols ^>=0.3,
Expand Down Expand Up @@ -175,9 +161,8 @@ test-suite sim-tests
Test.Ouroboros.Network.ConnectionManager
Test.Ouroboros.Network.RateLimiting
Test.Ouroboros.Network.RawBearer
Test.Ouroboros.Network.Server2.Sim
Test.Ouroboros.Network.Server.Sim
Test.Ouroboros.Network.Socket
Test.Ouroboros.Network.Subscription
Test.Simulation.Network.Snocket

build-depends:
Expand All @@ -188,10 +173,8 @@ test-suite sim-tests
containers,
contra-tracer,
directory,
dns,
io-classes,
io-sim,
iproute,
monoidal-synchronisation,
network,
network-mux,
Expand Down Expand Up @@ -247,21 +230,17 @@ test-suite io-tests
other-modules:
Test.Ouroboros.Network.Driver
Test.Ouroboros.Network.RawBearer
Test.Ouroboros.Network.Server2.IO
Test.Ouroboros.Network.Server.IO
Test.Ouroboros.Network.Socket
Test.Ouroboros.Network.Subscription

build-depends:
QuickCheck,
base >=4.14 && <4.21,
bytestring,
containers,
contra-tracer,
directory,
dns,
io-classes,
io-sim,
iproute,
monoidal-synchronisation,
network,
network-mux,
Expand Down
4 changes: 2 additions & 2 deletions ouroboros-network-framework/sim-tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Test.Tasty

import Test.Ouroboros.Network.ConnectionManager qualified as ConnectionManager
import Test.Ouroboros.Network.RateLimiting qualified as RateLimiting
import Test.Ouroboros.Network.Server2.Sim qualified as Server2
import Test.Ouroboros.Network.Server.Sim qualified as Server
import Test.Simulation.Network.Snocket qualified as Snocket

main :: IO ()
Expand All @@ -15,7 +15,7 @@ tests :: TestTree
tests =
testGroup "ouroboros-network-framework:sim-tests"
[ ConnectionManager.tests
, Server2.tests
, Server.tests
, RateLimiting.tests
, Snocket.tests
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ tests :: TestTree
tests =
testGroup "Ouroboros.Network.ConnectionManager"
[ -- generators, shrinkers properties
-- TODO: replace these tests with 'Test.Ouroboros.Network.Server2' simulation.
-- TODO: replace these tests with 'Test.Ouroboros.Network.Server' simulation.
testProperty "overwritten" unit_overwritten
, testProperty "timeoutExpired" unit_timeoutExpired
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-- for 'debugTracer'
{-# OPTIONS_GHC -Wno-redundant-constraints #-}

module Test.Ouroboros.Network.Server2.Sim (tests) where
module Test.Ouroboros.Network.Server.Sim (tests) where

import Control.Applicative (Alternative ((<|>)))
import Control.Concurrent.Class.MonadSTM qualified as LazySTM
Expand Down Expand Up @@ -86,9 +86,9 @@ import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..))
import Ouroboros.Network.Protocol.Handshake.Codec (noTimeLimitsHandshake,
timeLimitsHandshake)
import Ouroboros.Network.Protocol.Handshake.Unversioned
import Ouroboros.Network.Server (RemoteTransitionTrace)
import Ouroboros.Network.Server qualified as Server
import Ouroboros.Network.Server.RateLimiting (AcceptedConnectionsLimit (..))
import Ouroboros.Network.Server2 (RemoteTransitionTrace)
import Ouroboros.Network.Server2 qualified as Server
import Ouroboros.Network.Snocket (Snocket, TestAddress (..))
import Ouroboros.Network.Snocket qualified as Snocket

Expand Down Expand Up @@ -137,7 +137,7 @@ tests =
, testProperty "matured peers" prop_inbound_governor_maturedPeers
, testProperty "timeouts enforced" prop_timeouts_enforced
]
, testGroup "Server2"
, testGroup "Server"
[ testProperty "unidirectional Sim" prop_unidirectional_Sim
, testProperty "bidirectional Sim" prop_bidirectional_Sim
, testProperty "never above hardlimit" prop_never_above_hardlimit
Expand Down
Loading
Loading