Skip to content

Commit aa008c3

Browse files
cootjasagredo
authored andcommitted
ouroboros-consensus-diffusion adapted to network changes
1 parent d700f76 commit aa008c3

File tree

8 files changed

+52
-116
lines changed

8 files changed

+52
-116
lines changed

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ index-state:
1616
-- Bump this if you need newer packages from Hackage
1717
, hackage.haskell.org 2024-12-10T16:20:07Z
1818
-- Bump this if you need newer packages from CHaP
19-
, cardano-haskell-packages 2025-01-04T13:50:25Z
19+
, cardano-haskell-packages 2025-02-04T06:43:15Z
2020

2121
packages:
2222
ouroboros-consensus

flake.lock

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

ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ library unstable-cardano-tools
554554
ouroboros-consensus-protocol ^>=0.10,
555555
ouroboros-network,
556556
ouroboros-network-api,
557-
ouroboros-network-framework ^>=0.15,
557+
ouroboros-network-framework ^>=0.16,
558558
ouroboros-network-protocols,
559559
resource-registry,
560560
serialise ^>=0.2,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### Breaking
2+
3+
- Updated to `ouroboros-network-0.19.0.2` & `ouroboros-network-framework-0.16`.
4+
- `runWith` and `LowLevelRunNodeArgs` are no longer polymorphic in version
5+
data.
6+
- `NodeToNode.initiator`, `NodeToNode.initiatorAndResponder` take negotiated
7+
`NodeToNodeVersionData` as an argument instead of `PeerSharing` (config
8+
option).
9+
- `NodeToClient.respoinder` take negotiated `NodeToClientVersionData` as an
10+
argument.

ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ library
9191
mtl,
9292
network-mux ^>=0.6,
9393
ouroboros-consensus ^>=0.22,
94-
ouroboros-network ^>=0.19,
94+
ouroboros-network ^>=0.19.0.2,
9595
ouroboros-network-api ^>=0.12,
96-
ouroboros-network-framework ^>=0.15,
96+
ouroboros-network-framework ^>=0.16,
9797
ouroboros-network-protocols ^>=0.13,
9898
random,
9999
resource-registry ^>=0.1,

ouroboros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Network/NodeToClient.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ import qualified Ouroboros.Network.Driver.Stateful as Stateful
7474
import Ouroboros.Network.Mux
7575
import Ouroboros.Network.NodeToClient hiding
7676
(NodeToClientVersion (..))
77-
import qualified Ouroboros.Network.NodeToClient as N (NodeToClientVersion (..))
77+
import qualified Ouroboros.Network.NodeToClient as N (NodeToClientVersion (..),
78+
NodeToClientVersionData)
7879
import Ouroboros.Network.Protocol.ChainSync.Codec
7980
import Ouroboros.Network.Protocol.ChainSync.Server
8081
import Ouroboros.Network.Protocol.ChainSync.Type
@@ -465,9 +466,10 @@ mkApps kernel Tracers {..} Codecs {..} Handlers {..} =
465466
-- 'OuroborosApplication' for the node-to-client protocols.
466467
responder ::
467468
N.NodeToClientVersion
469+
-> N.NodeToClientVersionData
468470
-> Apps m (ConnectionId peer) b b b b a
469471
-> OuroborosApplicationWithMinimalCtx 'Mux.ResponderMode peer b m Void a
470-
responder version Apps {..} =
472+
responder version versionData Apps {..} =
471473
nodeToClientProtocols
472474
(NodeToClientProtocols {
473475
localChainSyncProtocol =
@@ -484,3 +486,4 @@ responder version Apps {..} =
484486
aTxMonitorServer (rcConnectionId ctx)
485487
})
486488
version
489+
versionData

ouroboros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Network/NodeToNode.hs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ import Ouroboros.Network.Mux
8989
import Ouroboros.Network.NodeToNode
9090
import Ouroboros.Network.PeerSelection.PeerMetric.Type
9191
(FetchedMetricsTracer, ReportPeerMetrics (..))
92-
import qualified Ouroboros.Network.PeerSelection.PeerSharing as PSTypes
9392
import Ouroboros.Network.PeerSharing (PeerSharingController,
9493
bracketPeerSharingClient, peerSharingClient,
9594
peerSharingServer)
@@ -809,10 +808,10 @@ mkApps kernel Tracers {..} mkCodecs ByteLimits {..} genChainSyncTimeout lopBucke
809808
initiator ::
810809
MiniProtocolParameters
811810
-> NodeToNodeVersion
812-
-> PSTypes.PeerSharing
811+
-> NodeToNodeVersionData
813812
-> Apps m addr b b b b b a c
814813
-> OuroborosBundleWithExpandedCtx 'Mux.InitiatorMode addr b m a Void
815-
initiator miniProtocolParameters version ownPeerSharing Apps {..} =
814+
initiator miniProtocolParameters version versionData Apps {..} =
816815
nodeToNodeProtocols
817816
miniProtocolParameters
818817
-- TODO: currently consensus is using 'ConnectionId' for its 'peer' type.
@@ -834,7 +833,7 @@ initiator miniProtocolParameters version ownPeerSharing Apps {..} =
834833
(InitiatorProtocolOnly (MiniProtocolCb (\ctx -> aPeerSharingClient version ctx)))
835834
})
836835
version
837-
ownPeerSharing
836+
versionData
838837

839838
-- | A bi-directional network application.
840839
--
@@ -844,10 +843,10 @@ initiator miniProtocolParameters version ownPeerSharing Apps {..} =
844843
initiatorAndResponder ::
845844
MiniProtocolParameters
846845
-> NodeToNodeVersion
847-
-> PSTypes.PeerSharing
846+
-> NodeToNodeVersionData
848847
-> Apps m addr b b b b b a c
849848
-> OuroborosBundleWithExpandedCtx 'Mux.InitiatorResponderMode addr b m a c
850-
initiatorAndResponder miniProtocolParameters version ownPeerSharing Apps {..} =
849+
initiatorAndResponder miniProtocolParameters version versionData Apps {..} =
851850
nodeToNodeProtocols
852851
miniProtocolParameters
853852
(NodeToNodeProtocols {
@@ -874,4 +873,4 @@ initiatorAndResponder miniProtocolParameters version ownPeerSharing Apps {..} =
874873
(MiniProtocolCb (\responderCtx -> aPeerSharingServer version responderCtx)))
875874
})
876875
version
877-
ownPeerSharing
876+
versionData

ouroboros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Node.hs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ data RunNodeArgs m addrNTN addrNTC blk (p2p :: Diffusion.P2P) = RunNodeArgs {
211211
-- 'runWith'. The @cardano-node@, for example, instead calls the 'run'
212212
-- abbreviation, which uses 'stdLowLevelRunNodeArgsIO' to indirectly specify
213213
-- these low-level values from the higher-level 'StdRunNodeArgs'.
214-
data LowLevelRunNodeArgs m addrNTN addrNTC versionDataNTN versionDataNTC blk
214+
data LowLevelRunNodeArgs m addrNTN addrNTC blk
215215
(p2p :: Diffusion.P2P) =
216216
LowLevelRunNodeArgs {
217217

@@ -269,15 +269,15 @@ data LowLevelRunNodeArgs m addrNTN addrNTC versionDataNTN versionDataNTC blk
269269
-- 'run' will not return before this does.
270270
, llrnRunDataDiffusion ::
271271
Diffusion.Applications
272-
addrNTN NodeToNodeVersion versionDataNTN
273-
addrNTC NodeToClientVersion versionDataNTC
272+
addrNTN NodeToNodeVersion NodeToNodeVersionData
273+
addrNTC NodeToClientVersion NodeToClientVersionData
274274
m NodeToNodeInitiatorResult
275275
-> Diffusion.ExtraApplications p2p addrNTN m NodeToNodeInitiatorResult
276276
-> m ()
277277

278-
, llrnVersionDataNTC :: versionDataNTC
278+
, llrnVersionDataNTC :: NodeToClientVersionData
279279

280-
, llrnVersionDataNTN :: versionDataNTN
280+
, llrnVersionDataNTN :: NodeToNodeVersionData
281281

282282
-- | node-to-node protocol versions to run.
283283
, llrnNodeToNodeVersions :: Map NodeToNodeVersion (BlockNodeToNodeVersion blk)
@@ -396,7 +396,7 @@ type NetworkAddr addr = (
396396
-- network layer.
397397
--
398398
-- This function runs forever unless an exception is thrown.
399-
runWith :: forall m addrNTN addrNTC versionDataNTN versionDataNTC blk p2p.
399+
runWith :: forall m addrNTN addrNTC blk p2p.
400400
( RunNode blk
401401
, IOLike m
402402
, Hashable addrNTN -- the constraint comes from `initNodeKernel`
@@ -406,7 +406,7 @@ runWith :: forall m addrNTN addrNTC versionDataNTN versionDataNTC blk p2p.
406406
=> RunNodeArgs m addrNTN addrNTC blk p2p
407407
-> (NodeToNodeVersion -> addrNTN -> CBOR.Encoding)
408408
-> (NodeToNodeVersion -> forall s . CBOR.Decoder s addrNTN)
409-
-> LowLevelRunNodeArgs m addrNTN addrNTC versionDataNTN versionDataNTC blk p2p
409+
-> LowLevelRunNodeArgs m addrNTN addrNTC blk p2p
410410
-> m ()
411411
runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
412412

@@ -601,8 +601,8 @@ runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
601601
-> NodeKernel m addrNTN (ConnectionId addrNTC) blk
602602
-> PeerMetrics m addrNTN
603603
-> ( Diffusion.Applications
604-
addrNTN NodeToNodeVersion versionDataNTN
605-
addrNTC NodeToClientVersion versionDataNTC
604+
addrNTN NodeToNodeVersion NodeToNodeVersionData
605+
addrNTC NodeToClientVersion NodeToClientVersionData
606606
m NodeToNodeInitiatorResult
607607
, Diffusion.ExtraApplications p2p addrNTN m NodeToNodeInitiatorResult
608608
)
@@ -640,7 +640,8 @@ runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
640640
[ simpleSingletonVersions
641641
version
642642
llrnVersionDataNTN
643-
(NTN.initiator miniProtocolParams version rnPeerSharing
643+
(\versionData ->
644+
NTN.initiator miniProtocolParams version versionData
644645
-- Initiator side won't start responder side of Peer
645646
-- Sharing protocol so we give a dummy implementation
646647
-- here.
@@ -652,7 +653,8 @@ runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
652653
[ simpleSingletonVersions
653654
version
654655
llrnVersionDataNTN
655-
(NTN.initiatorAndResponder miniProtocolParams version rnPeerSharing
656+
(\versionData ->
657+
NTN.initiatorAndResponder miniProtocolParams version versionData
656658
$ ntnApps blockVersion)
657659
| (version, blockVersion) <- Map.toList llrnNodeToNodeVersions
658660
],
@@ -661,7 +663,7 @@ runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
661663
[ simpleSingletonVersions
662664
version
663665
llrnVersionDataNTC
664-
(NTC.responder version $ ntcApps blockVersion version)
666+
(\versionData -> NTC.responder version versionData $ ntcApps blockVersion version)
665667
| (version, blockVersion) <- Map.toList llrnNodeToClientVersions
666668
],
667669
Diffusion.daLedgerPeersCtx =
@@ -896,8 +898,6 @@ stdLowLevelRunNodeArgsIO ::
896898
IO
897899
RemoteAddress
898900
LocalAddress
899-
NodeToNodeVersionData
900-
NodeToClientVersionData
901901
blk
902902
p2p)
903903
stdLowLevelRunNodeArgsIO RunNodeArgs{ rnProtocolInfo

0 commit comments

Comments
 (0)