Skip to content

Commit

Permalink
Updates ouroboros-network to fix PeerSharing
Browse files Browse the repository at this point in the history
  • Loading branch information
bolt12 committed Oct 2, 2023
1 parent 71e6cbb commit 7f88a80
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
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

- Changes `NoPeerSharing` to `PeerSharingDisabled` ([#4644](https://github.com/input-output-hk/ouroboros-network/pull/4644))

### Breaking

- Adds `NodeToNodeVersion` to the arguments of `immDBServer` function.

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ 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
(decodeRemoteAddress, encodeRemoteAddress)
import Ouroboros.Network.NodeToNode.Version (decodeRemoteAddress,
encodeRemoteAddress)
import qualified Ouroboros.Network.Snocket as Snocket
import Ouroboros.Network.Socket (configureSocket)
import System.FS.API (SomeHasFS (..))
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,18 @@
<!--
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

### Breaking

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

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 {
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 @@ -114,12 +114,13 @@ import Ouroboros.Network.NodeToNode (DiffusionMode (..),
ExceptionInHandler (..), MiniProtocolParameters,
NodeToNodeVersionData (..), RemoteAddress, Socket,
blockFetchPipeliningMax, defaultMiniProtocolParameters)
import Ouroboros.Network.NodeToNode.Version (decodeRemoteAddress,
encodeRemoteAddress)
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.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
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,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 +1347,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

0 comments on commit 7f88a80

Please sign in to comment.