Skip to content

Commit abf097c

Browse files
committed
Add parameter types for ObjectDiffusion/PerasCertDiffusion
1 parent bca44ca commit abf097c

File tree

2 files changed

+42
-6
lines changed
  • ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ObjectDiffusion
  • ouroboros-network/src/Ouroboros/Network

2 files changed

+42
-6
lines changed

ouroboros-network-protocols/src/Ouroboros/Network/Protocol/ObjectDiffusion/Type.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ module Ouroboros.Network.Protocol.ObjectDiffusion.Type
3838
BlockingReplyList (..),
3939
NumObjectIdsToAck (..),
4040
NumObjectIdsToReq (..),
41+
NumObjectsToReq (..),
42+
NumObjectsInFifo (..),
4143
-- re-exports
4244
SizeInBytes (..),
4345
)
@@ -170,6 +172,20 @@ newtype NumObjectIdsToReq = NumObjectIdsToReq {getNumObjectIdsToReq :: Word16}
170172
deriving (Monoid) via (Sum Word16)
171173
deriving (Show) via (Quiet NumObjectIdsToReq)
172174

175+
newtype NumObjectsToReq = NumObjectsToReq {getNumObjectsToReq :: Word16}
176+
deriving (Eq, Ord, NFData, Generic)
177+
deriving newtype (Num, Enum, Real, Integral, Bounded, NoThunks)
178+
deriving (Semigroup) via (Sum Word16)
179+
deriving (Monoid) via (Sum Word16)
180+
deriving (Show) via (Quiet NumObjectsToReq)
181+
182+
newtype NumObjectsInFifo = NumObjectsInFifo {getNumObjectsInFifo :: Word16}
183+
deriving (Eq, Ord, NFData, Generic)
184+
deriving newtype (Num, Enum, Real, Integral, Bounded, NoThunks)
185+
deriving (Semigroup) via (Sum Word16)
186+
deriving (Monoid) via (Sum Word16)
187+
deriving (Show) via (Quiet NumObjectsInFifo)
188+
173189
-- | There are some constraints of the protocol that are not captured in the
174190
-- types of the messages, but are documented with the messages. Violation
175191
-- of these constraints is also a protocol error. The constraints are intended

ouroboros-network/src/Ouroboros/Network/NodeToNode.hs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import Ouroboros.Network.Snocket
103103
import Ouroboros.Network.Socket
104104
import Ouroboros.Network.Util.ShowProxy (ShowProxy, showProxy)
105105
import Ouroboros.Network.Protocol.ObjectDiffusion.Type (NumObjectIdsToAck)
106+
import Ouroboros.Network.Protocol.ObjectDiffusion.Type (NumObjectsInFifo)
106107

107108

108109
-- The Handshake tracer types are simply terrible.
@@ -162,16 +163,35 @@ data MiniProtocolParameters = MiniProtocolParameters {
162163
-- ^ maximal number of unacked tx (pipelining is bounded by twice this
163164
-- number)
164165

165-
certDiffusionMaxUnacked :: !NumObjectIdsToAck
166+
perasCertDiffusionMaxFifoLength :: !NumObjectsInFifo
167+
-- ^ Maximum number of PerasCerts in the outbound peer's outstanding FIFO.
168+
--
169+
-- This indirectly limits the number of pipelined requests from the inbound peer:
170+
-- the inbound peer can only request @n@ new IDs if the execution of preceding
171+
-- requests would result in at least @n@ empty seats in the FIFO.
172+
--
173+
-- In the worst case:
174+
--
175+
-- * The inbound peer requests IDs and objects one by one.
176+
-- * The inbound peer is aware of @perasCertDiffusionMaxFifoLength@ IDs for objects
177+
-- it hasn't requested yet (i.e., the FIFO is full).
178+
--
179+
-- Then, the inbound peer can pipeline at most @perasCertDiffusionMaxFifoLength@
180+
-- requests for one object each (with a known ID), and up to
181+
-- @perasCertDiffusionMaxFifoLength@ requests for one new ID each.
182+
--
183+
-- So, the theoretical maximum pipeline size is
184+
-- @2 * perasCertDiffusionMaxFifoLength@, but in practice the pipeline size will
185+
-- be much smaller, as the inbound peer typically batches requests.
166186
}
167187

168188
defaultMiniProtocolParameters :: MiniProtocolParameters
169189
defaultMiniProtocolParameters = MiniProtocolParameters {
170-
chainSyncPipeliningLowMark = 200
171-
, chainSyncPipeliningHighMark = 300
172-
, blockFetchPipeliningMax = 100
173-
, txSubmissionMaxUnacked = 10
174-
, certDiffusionMaxUnacked = 10
190+
chainSyncPipeliningLowMark = 200
191+
, chainSyncPipeliningHighMark = 300
192+
, blockFetchPipeliningMax = 100
193+
, txSubmissionMaxUnacked = 10
194+
, perasCertDiffusionMaxFifoLength = 10
175195
}
176196

177197
-- | Make an 'OuroborosApplication' for the bundle of mini-protocols that

0 commit comments

Comments
 (0)