Skip to content

Commit

Permalink
handshake: ProtocolTimeLmits in ouroboros-network
Browse files Browse the repository at this point in the history
* 'timeLimitsHandshake' for 'node-to-node': 10s timeout
* 'noTimeLimitsHandshake' for node-to-client': no timeout

The node-to-client protocol is assumed to be executed in a safe
environment, so there's no reason to introduce a timeout.  We spotted
a handshake timeout on node-to-client protocol in a node that had large
valency in a benchmarking cluster.  This patch restores node-to-client
handshake no timoeut before #2956.
  • Loading branch information
coot authored and karknu committed Mar 17, 2021
1 parent efca314 commit 0988be8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ouroboros-network/demo/chain-sync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ clientChainSync sockPaths = withIOManager $ \iocp ->
connectToNode
(localSnocket iocp sockPath)
unversionedHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec unversionedProtocolDataCodec)
nullNetworkConnectTracers
acceptableVersion
Expand Down Expand Up @@ -187,6 +188,7 @@ serverChainSync sockAddr = withIOManager $ \iocp -> do
(AcceptedConnectionsLimit maxBound maxBound 0)
(localAddressFromPath sockAddr)
unversionedHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec unversionedProtocolDataCodec)
acceptableVersion
(simpleSingletonVersions
Expand Down Expand Up @@ -358,6 +360,7 @@ clientBlockFetch sockAddrs = withIOManager $ \iocp -> do
connectToNode
(localSnocket iocp defaultLocalSocketAddrPath)
unversionedHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec unversionedProtocolDataCodec)
nullNetworkConnectTracers
acceptableVersion
Expand Down Expand Up @@ -413,6 +416,7 @@ serverBlockFetch sockAddr = withIOManager $ \iocp -> do
(AcceptedConnectionsLimit maxBound maxBound 0)
(localAddressFromPath sockAddr)
unversionedHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec unversionedProtocolDataCodec)
acceptableVersion
(simpleSingletonVersions
Expand Down
3 changes: 3 additions & 0 deletions ouroboros-network/src/Ouroboros/Network/NodeToClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ connectTo
connectTo snocket tracers versions path =
connectToNode snocket
nodeToClientHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToClientCodecCBORTerm)
tracers
acceptableVersion
Expand Down Expand Up @@ -270,6 +271,7 @@ withServer sn tracers networkState sd versions errPolicies =
(AcceptedConnectionsLimit maxBound maxBound 0)
sd
nodeToClientHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToClientCodecCBORTerm)
acceptableVersion
(SomeResponderApplication <$> versions)
Expand Down Expand Up @@ -316,6 +318,7 @@ ncSubscriptionWorker
(connectToNode'
sn
nodeToClientHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToClientCodecCBORTerm)
(NetworkConnectTracers nsMuxTracer nsHandshakeTracer)
acceptableVersion
Expand Down
5 changes: 4 additions & 1 deletion ouroboros-network/src/Ouroboros/Network/NodeToNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ connectTo
-> Socket.SockAddr
-> IO ()
connectTo sn tr =
connectToNode sn nodeToNodeHandshakeCodec
connectToNode sn nodeToNodeHandshakeCodec timeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
tr acceptableVersion

Expand Down Expand Up @@ -445,6 +445,7 @@ withServer sn tracers networkState acceptedConnectionsLimit sd versions errPolic
acceptedConnectionsLimit
sd
nodeToNodeHandshakeCodec
timeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
acceptableVersion
(SomeResponderApplication <$> versions)
Expand Down Expand Up @@ -487,6 +488,7 @@ ipSubscriptionWorker
(connectToNode'
sn
nodeToNodeHandshakeCodec
timeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
(NetworkConnectTracers nsMuxTracer nsHandshakeTracer)
acceptableVersion
Expand Down Expand Up @@ -530,6 +532,7 @@ dnsSubscriptionWorker
(connectToNode'
sn
nodeToNodeHandshakeCodec
timeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
(NetworkConnectTracers ndstMuxTracer ndstHandshakeTracer)
acceptableVersion
Expand Down
4 changes: 4 additions & 0 deletions ouroboros-network/test/Test/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import Ouroboros.Network.Protocol.Handshake.Codec
(cborTermVersionDataCodec)
import Ouroboros.Network.Protocol.Handshake.Version
(acceptableVersion)
import Ouroboros.Network.Protocol.Handshake.Codec
(noTimeLimitsHandshake)
import Ouroboros.Network.Testing.Serialise
import Ouroboros.Network.Util.ShowProxy

Expand Down Expand Up @@ -157,6 +159,7 @@ demo chain0 updates = withIOManager $ \iocp -> do
(AcceptedConnectionsLimit maxBound maxBound 0)
producerAddress
nodeToNodeHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
acceptableVersion
(simpleSingletonVersions
Expand All @@ -171,6 +174,7 @@ demo chain0 updates = withIOManager $ \iocp -> do
(connectToNode
(socketSnocket iocp)
nodeToNodeHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
nullNetworkConnectTracers
acceptableVersion
Expand Down

0 comments on commit 0988be8

Please sign in to comment.