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

Don't wait forever in TokNext TokMustReply #1871

Merged
merged 1 commit into from
Mar 31, 2020
Merged
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
Expand Up @@ -759,6 +759,7 @@ runThreadNetwork ThreadNetworkArgs
-- node
nullDebugProtocolTracers
(customProtocolCodecs pInfoConfig)
Nothing
(protocolHandlers nodeArgs nodeKernel)

-- In practice, a robust wallet/user can persistently add a transaction
Expand Down
2 changes: 2 additions & 0 deletions ouroboros-consensus/src/Ouroboros/Consensus/Node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ run tracers protocolTracers chainDbTracer diffusionTracers diffusionArguments
nodeKernel
protocolTracers
(protocolCodecs (getTopLevelConfig nodeKernel) version)
(Just 70) -- timeout after waiting this long for the next header
-- 70s allows for 3 slots (3 * 20s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 * 20s /= 70s 😏

(protocolHandlers nodeArgs nodeKernel)

mkDiffusionApplications
Expand Down
7 changes: 4 additions & 3 deletions ouroboros-consensus/src/Ouroboros/Consensus/NodeNetwork.hs
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,10 @@ consensusNetworkApps
=> NodeKernel m peer blk
-> ProtocolTracers m peer localPeer blk failure
-> ProtocolCodecs blk failure m bytesCS bytesCS bytesBF bytesBF bytesTX bytesLCS bytesLTX bytesLSQ
-> Maybe DiffTime -- Workaround for #1882, test cases that can't cope with timeouts
-> ProtocolHandlers m peer blk
-> NetworkApplication m peer localPeer bytesCS bytesBF bytesTX bytesLCS bytesLTX bytesLSQ ()
consensusNetworkApps kernel ProtocolTracers {..} ProtocolCodecs {..} ProtocolHandlers {..} =
consensusNetworkApps kernel ProtocolTracers {..} ProtocolCodecs {..} chainSyncTimeout ProtocolHandlers {..} =
NetworkApplication {
naChainSyncClient,
naChainSyncServer,
Expand Down Expand Up @@ -534,7 +535,7 @@ consensusNetworkApps kernel ProtocolTracers {..} ProtocolCodecs {..} ProtocolHan
(contramap (TraceLabelPeer them) ptChainSyncTracer)
pcChainSyncCodec
(byteLimitsChainSync (const 0)) -- TODO: Real Bytelimits, see #1727
timeLimitsChainSync
(timeLimitsChainSync chainSyncTimeout)
channel
$ chainSyncClientPeerPipelined
$ phChainSyncClient varCandidate
Expand All @@ -548,7 +549,7 @@ consensusNetworkApps kernel ProtocolTracers {..} ProtocolCodecs {..} ProtocolHan
(contramap (TraceLabelPeer them) ptChainSyncSerialisedTracer)
pcChainSyncCodecSerialised
(byteLimitsChainSync (const 0)) -- TODO: Real Bytelimits, see #1727
timeLimitsChainSync
(timeLimitsChainSync chainSyncTimeout)
channel
$ chainSyncServerPeer
$ phChainSyncServer registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ byteLimitsChainSync = ProtocolSizeLimits stateToLimit
--
-- `TokIdle` No timeout
-- `TokNext TokCanAwait` `longWait` timeout
-- `TokNext TokMustReply` No timeout
-- `TokIntersect` `longWait timeout
timeLimitsChainSync :: ProtocolTimeLimits (ChainSync header tip)
timeLimitsChainSync = ProtocolTimeLimits stateToLimit
-- `TokNext TokMustReply` consensusTimeout timeout
-- `TokIntersect` `longWait` timeout
timeLimitsChainSync :: Maybe DiffTime -> ProtocolTimeLimits (ChainSync header tip)
timeLimitsChainSync consensusTimeout = ProtocolTimeLimits stateToLimit
where
stateToLimit :: forall (pr :: PeerRole) (st :: ChainSync header tip).
PeerHasAgency pr st -> Maybe DiffTime
stateToLimit (ClientAgency TokIdle) = waitForever
stateToLimit (ServerAgency (TokNext TokCanAwait)) = shortWait
stateToLimit (ServerAgency (TokNext TokMustReply)) = waitForever
stateToLimit (ServerAgency (TokNext TokMustReply)) = consensusTimeout
stateToLimit (ServerAgency TokIntersect) = shortWait

-- | The main CBOR 'Codec' for the 'ChainSync' protocol.
Expand Down