Skip to content

Commit 9a2087c

Browse files
authored
Merge pull request #4887 from IntersectMBO/coot/tx-submission
TX Submission Logic
2 parents 113d308 + f4bb0f6 commit 9a2087c

File tree

39 files changed

+6223
-652
lines changed

39 files changed

+6223
-652
lines changed

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ index-state:
1818
, hackage.haskell.org 2025-08-05T15:28:56Z
1919

2020
-- Bump this if you need newer packages from CHaP
21-
, cardano-haskell-packages 2025-02-15T18:39:38Z
21+
, cardano-haskell-packages 2025-03-18T17:41:11Z
2222

2323
packages: ./cardano-ping
2424
./monoidal-synchronisation

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

network-mux/src/Network/Mux/Bearer/Socket.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ socketAsBearer sduSize batchSize readBuffer_m sduTimeout egressInterval sd =
221221
let ts32 = Mx.timestampMicrosecondsLow32Bits ts
222222
buf = map (Mx.encodeSDU .
223223
(\sdu -> Mx.setTimestamp sdu (Mx.RemoteClockModel ts32))) sdus
224-
r <- timeout ((fromIntegral $ length sdus) * sduTimeout) $
224+
r <- timeout (fromIntegral (length sdus) * sduTimeout) $
225225
Socket.sendMany sd (concatMap BL.toChunks buf)
226226
`catch` Mx.handleIOException "sendAll errored"
227227
case r of

network-mux/src/Network/Mux/Codec.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,22 @@ import Network.Mux.Types
1818
-- > 0 1 2 3
1919
-- > 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2020
-- > +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21-
-- > | transmission time |
21+
-- > | transmission time |
2222
-- > +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23-
-- > |M| conversation id | length |
23+
-- > |d| mini-protocol number | length |
2424
-- > +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2525
--
2626
-- All fields are in big endian byte order.
2727
--
28+
-- * transmission time: time when the SDU was sent
29+
-- * @d@: mini-protocol direction (`MiniProtocolDir`):
30+
--
31+
-- * 1 - initiator direction
32+
-- * 0 - responder direction
33+
--
34+
-- * mini-protocol number (`MiniProtocolNum`)
35+
-- * length: length of the payload
36+
--
2837
encodeSDU :: SDU -> BL.ByteString
2938
encodeSDU sdu =
3039
let hdr = Bin.runPut enc in

nix/ouroboros-network.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ let
114114
packages.ouroboros-network-protocols.components.tests.test.preCheck =
115115
if buildSystem == "x86_64-linux" then "export GHCRTS=-M800M" else "";
116116
packages.ouroboros-network.components.tests.sim-tests.preCheck =
117-
if buildSystem == "x86_64-linux" then "export GHCRTS=-M2400M" else "";
117+
if buildSystem == "x86_64-linux" then "export GHCRTS=-M7000M" else "";
118118
})
119119
({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isWindows {
120120
packages.basement.configureFlags = [ "--hsc2hs-options=--cflag=-Wno-int-conversion" ];

ouroboros-network-api/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
* `IsLedgerPeer` added to `Ouroboros.Network.LedgerPeers.Types` module.
3030
* Added `ProtocolTimeLimitsWithRnd` to `Ouroboros.Network.Protocol.Limits`
31+
* Derived `Bounded` instance for `SizeInBytes`.
3132

3233
## 0.14.1.0 -- 2025-07-17
3334

ouroboros-network-api/src/Ouroboros/Network/SizeInBytes.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Quiet (Quiet (..))
1717
newtype SizeInBytes = SizeInBytes { getSizeInBytes :: Word32 }
1818
deriving (Eq, Ord)
1919
deriving Show via Quiet SizeInBytes
20+
deriving Bounded via Word32
2021
deriving Enum via Word32
2122
deriving Num via Word32
2223
deriving Real via Word32

ouroboros-network-framework/src/Ouroboros/Network/Snocket.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ instance Hashable LocalAddress where
219219
newtype TestAddress addr = TestAddress { getTestAddress :: addr }
220220
deriving (Eq, Ord, Generic, NFData)
221221
deriving NoThunks via InspectHeap (TestAddress addr)
222-
deriving Show via Quiet (TestAddress addr)
222+
223+
instance Show addr => Show (TestAddress addr) where
224+
showsPrec d (TestAddress addr) = showParen (d > app_prec) $
225+
showString "TestAddress " . showsPrec (app_prec+1) addr
226+
where app_prec = 10
223227

224228
instance Hashable addr => Hashable (TestAddress addr)
225229

ouroboros-network-protocols/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* `timeLimitsChainSync` changed type: it is a function which takes the idle timeout as an argument.
1717
* `Ouroboros.Network.Protocols.TxSubmission2.Codec.{encode,decode}TxSubmission2`
1818
are no longer exported.
19+
* `CollectPipelined` constructor for `TxSubmission2.Server` was modified: now
20+
one can run a monadic action in the continuation when no message is available.
1921

2022
### Non-breaking changes
2123

ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Server.hs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ module Ouroboros.Network.Protocol.TxSubmission2.Server
2525
) where
2626

2727
import Data.List.NonEmpty (NonEmpty)
28+
import Data.Map.Strict (Map)
29+
import Data.Map.Strict qualified as Map
2830

2931
import Network.TypedProtocol.Core
3032
import Network.TypedProtocol.Peer.Server
@@ -51,7 +53,7 @@ data Collect txid tx =
5153
-- contains the transactions sent, but this pairs them up with the
5254
-- transactions requested. This is because the peer can determine that
5355
-- some transactions are no longer needed.
54-
| CollectTxs [txid] [tx]
56+
| CollectTxs (Map txid SizeInBytes) [tx]
5557

5658

5759
data ServerStIdle (n :: N) txid tx m a where
@@ -77,16 +79,16 @@ data ServerStIdle (n :: N) txid tx m a where
7779
-- |
7880
--
7981
SendMsgRequestTxsPipelined
80-
:: [txid]
82+
:: Map txid SizeInBytes
8183
-> m (ServerStIdle (S n) txid tx m a)
8284
-> ServerStIdle n txid tx m a
8385

8486
-- | Collect a pipelined result.
8587
--
8688
CollectPipelined
87-
:: Maybe (ServerStIdle (S n) txid tx m a)
88-
-> (Collect txid tx -> m (ServerStIdle n txid tx m a))
89-
-> ServerStIdle (S n) txid tx m a
89+
:: Maybe (m (ServerStIdle (S n) txid tx m a))
90+
-> (Collect txid tx -> m ( ServerStIdle n txid tx m a))
91+
-> ServerStIdle (S n) txid tx m a
9092

9193

9294
-- | Transform a 'TxSubmissionServerPipelined' into a 'PeerPipelined'.
@@ -127,12 +129,12 @@ txSubmissionServerPeerPipelined (TxSubmissionServerPipelined server) =
127129

128130
go (SendMsgRequestTxsPipelined txids k) =
129131
YieldPipelined
130-
(MsgRequestTxs txids)
132+
(MsgRequestTxs $ Map.keys txids)
131133
(ReceiverAwait \case
132134
MsgReplyTxs txs -> ReceiverDone (CollectTxs txids txs))
133135
(Effect (go <$> k))
134136

135137
go (CollectPipelined mNone collect) =
136-
Collect (fmap go mNone)
137-
(Effect . fmap go . collect)
138+
Collect (Effect . fmap go <$> mNone)
139+
(Effect . fmap go . collect)
138140

0 commit comments

Comments
 (0)