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

Updates ouroboros-network to fix PeerSharing #383

Merged
merged 4 commits into from
Nov 13, 2023
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
9 changes: 7 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repository cardano-haskell-packages
-- update either of these.
index-state:
-- Bump this if you need newer packages from Hackage
, hackage.haskell.org 2023-08-02T14:18:01Z
, hackage.haskell.org 2023-11-07T14:32:35Z
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2023-10-26T00:00:00Z
, cardano-haskell-packages 2023-11-03T12:09:05Z

packages:
ouroboros-consensus
Expand All @@ -31,3 +31,8 @@ tests: true
benchmarks: true

import: ./asserts.cabal

constraints:
-- Plutus is incompatible with 0.1.5 because of the NoThunks (Identity a)
-- instance, once they fix that we shall remove this constraint.
nothunks == 0.1.4
62 changes: 40 additions & 22 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Patch

- A bullet item for the Patch category.

-->
### Non-Breaking

- Updates dependency on `ouroboros-network-api` to `0.6.0`.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ library
, nothunks
, ouroboros-consensus ^>=0.13
, ouroboros-consensus-protocol ^>=0.6.0.0
, ouroboros-network-api ^>=0.5.1
, ouroboros-network-api ^>=0.6.0
, serialise ^>=0.2
, small-steps
, sop-core ^>=0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Ouroboros.Network.ErrorPolicy (nullErrorPolicies)
import Ouroboros.Network.IOManager (withIOManager)
import Ouroboros.Network.Mux
import qualified Ouroboros.Network.NodeToNode as N2N
import Ouroboros.Network.PeerSelection.PeerSharing
import Ouroboros.Network.PeerSelection.PeerSharing.Codec
(decodeRemoteAddress, encodeRemoteAddress)
import qualified Ouroboros.Network.Snocket as Snocket
import Ouroboros.Network.Socket (configureSocket)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ immDBServer ::
, SupportedNetworkProtocolVersion blk
)
=> CodecConfig blk
-> (addr -> CBOR.Encoding)
-> (forall s . CBOR.Decoder s addr)
-> (NodeToNodeVersion -> addr -> CBOR.Encoding)
-> (NodeToNodeVersion -> forall s . CBOR.Decoder s addr)
-> ImmutableDB m blk
-> NetworkMagic
-> Versions NodeToNodeVersion NodeToNodeVersionData
Expand All @@ -90,7 +90,7 @@ immDBServer codecCfg encAddr decAddr immDB networkMagic = do
stdVersionDataNTN
networkMagic
N2N.InitiatorOnlyDiffusionMode
NoPeerSharing
PeerSharingDisabled
}

application ::
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Patch

- A bullet item for the Patch category.

-->
### Breaking

- Adds `NodeToNodeVersion` to the arguments of `defaultCodecs` and `runWith` functions.

Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ library
, Ouroboros.Consensus.Node.NetworkProtocolVersion

build-depends:
, base >=4.14 && <4.19
, bytestring >=0.10 && <0.12
, base >=4.14 && <4.19
, bytestring >=0.10 && <0.12
, cborg ^>=0.2.2
, containers >=0.5 && <0.7
, containers >=0.5 && <0.7
, contra-tracer
, deepseq
, filepath
Expand All @@ -77,10 +77,10 @@ library
, io-classes ^>=1.2
, mtl
, ouroboros-consensus ^>=0.13
, ouroboros-network ^>=0.9.1
, ouroboros-network-api ^>=0.5.1
, ouroboros-network-framework ^>=0.9
, ouroboros-network-protocols ^>=0.5.2
, ouroboros-network ^>=0.10.0
, ouroboros-network-api ^>=0.6.0
, ouroboros-network-framework ^>=0.10
, ouroboros-network-protocols ^>=0.6.0
, random
, serialise ^>=0.2
, si-timers ^>=1.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ defaultCodecs :: forall m blk addr.
)
=> CodecConfig blk
-> BlockNodeToNodeVersion blk
-> (addr -> CBOR.Encoding)
-> (forall s . CBOR.Decoder s addr)
-> (NodeToNodeVersion -> addr -> CBOR.Encoding)
-> (NodeToNodeVersion -> forall s . CBOR.Decoder s addr)
-> NodeToNodeVersion
-> Codecs blk addr DeserialiseFailure m
ByteString ByteString ByteString ByteString ByteString ByteString ByteString
defaultCodecs ccfg version encAddr decAddr _nodeToNodeVersion = Codecs {
defaultCodecs ccfg version encAddr decAddr nodeToNodeVersion = Codecs {
nfrisby marked this conversation as resolved.
Show resolved Hide resolved
cChainSyncCodec =
codecChainSync
enc
Expand Down Expand Up @@ -325,7 +325,7 @@ defaultCodecs ccfg version encAddr decAddr _nodeToNodeVersion = Codecs {

, cKeepAliveCodec = codecKeepAlive_v2

, cPeerSharingCodec = codecPeerSharing encAddr decAddr
, cPeerSharingCodec = codecPeerSharing (encAddr nodeToNodeVersion) (decAddr nodeToNodeVersion)
}
where
p :: Proxy blk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ import Ouroboros.Network.PeerSelection.LedgerPeers
(LedgerPeersConsensusInterface (..))
import Ouroboros.Network.PeerSelection.PeerMetric (PeerMetrics,
newPeerMetric, reportMetric)
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing,
decodeRemoteAddress, encodeRemoteAddress)
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing)
import Ouroboros.Network.PeerSelection.PeerSharing.Codec
(decodeRemoteAddress, encodeRemoteAddress)
import Ouroboros.Network.Protocol.Limits (shortWait)
import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingAmount)
import Ouroboros.Network.RethrowPolicy
Expand Down Expand Up @@ -309,8 +310,8 @@ runWith :: forall m addrNTN addrNTC versionDataNTN versionDataNTC blk p2p.
, NetworkAddr addrNTN
)
=> RunNodeArgs m addrNTN addrNTC blk p2p
-> (addrNTN -> CBOR.Encoding)
-> (forall s . CBOR.Decoder s addrNTN)
-> (NodeToNodeVersion -> addrNTN -> CBOR.Encoding)
-> (NodeToNodeVersion -> forall s . CBOR.Decoder s addrNTN)
-> LowLevelRunNodeArgs m addrNTN addrNTC versionDataNTN versionDataNTC blk p2p
-> m ()
runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
Expand Down Expand Up @@ -420,8 +421,8 @@ runWith RunNodeArgs{..} encAddrNtN decAddrNtN LowLevelRunNodeArgs{..} =
:: NodeKernelArgs m addrNTN (ConnectionId addrNTC) blk
-> NodeKernel m addrNTN (ConnectionId addrNTC) blk
-> PeerMetrics m addrNTN
-> (addrNTN -> CBOR.Encoding)
-> (forall s . CBOR.Decoder s addrNTN)
-> (NodeToNodeVersion -> addrNTN -> CBOR.Encoding)
-> (NodeToNodeVersion -> forall s . CBOR.Decoder s addrNTN)
-> BlockNodeToNodeVersion blk
-> (PeerSharingAmount -> m [addrNTN])
-- ^ Peer Sharing result computation callback
Expand Down Expand Up @@ -739,6 +740,7 @@ stdChainSyncTimeout = do
{ canAwaitTimeout = shortWait
, intersectTimeout = shortWait
, mustReplyTimeout
, idleTimeout = Just 3673
}

stdVersionDataNTN :: NetworkMagic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ runThreadNetwork systemTime ThreadNetworkArgs
{ canAwaitTimeout = waitForever
, intersectTimeout = waitForever
, mustReplyTimeout = waitForever
, idleTimeout = waitForever
})
nullMetric
-- The purpose of this test is not testing protocols, so
Expand Down Expand Up @@ -1097,7 +1098,7 @@ runThreadNetwork systemTime ThreadNetworkArgs
NTN.cPeerSharingCodec NTN.identityCodecs
}
where
binaryProtocolCodecs = NTN.defaultCodecs (configCodec cfg) blockVersion encodeNodeId decodeNodeId ntnVersion
binaryProtocolCodecs = NTN.defaultCodecs (configCodec cfg) blockVersion (const encodeNodeId) (const decodeNodeId) ntnVersion

-- | Sum of 'CodecFailure' (from @identityCodecs@) and 'DeserialiseFailure'
-- (from @defaultCodecs@).
Expand Down Expand Up @@ -1347,7 +1348,7 @@ directedEdgeInner registry clock (version, blockVersion) (cfg, calcMessageDelay)
_ -> pure ()
where
codec =
NTN.cChainSyncCodec $ NTN.defaultCodecs cfg blockVersion encodeNodeId decodeNodeId version
NTN.cChainSyncCodec $ NTN.defaultCodecs cfg blockVersion (const encodeNodeId) (const decodeNodeId) version

-- | Variant of 'createConnectChannels' with intermediate queues for
-- delayed-but-in-order messages
Expand Down
4 changes: 2 additions & 2 deletions ouroboros-consensus/ouroboros-consensus.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ library
, measures
, mtl
, nothunks ^>=0.1.2
, ouroboros-network-api ^>=0.5.1
, ouroboros-network-api ^>=0.6.0
, ouroboros-network-mock ^>=0.1.0.1
, ouroboros-network-protocols ^>=0.5
, ouroboros-network-protocols ^>=0.6
, psqueues ^>=0.2.3
, quiet ^>=0.2
, semialign >=1.1
Expand Down