Skip to content

Commit

Permalink
Update dependencies for handshake query
Browse files Browse the repository at this point in the history
  • Loading branch information
jprider63 committed Apr 14, 2023
1 parent a158a67 commit ab09b2e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/IPC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ mkVersionedProtocols networkid ptcl unversionedClients =
ptclVersion
NodeToClientVersionData {
networkMagic = toNetworkMagic networkid
, query = False
}
(\_connid _ctl -> protocols (unversionedClients ptclVersion) ptclBlockVersion ptclVersion))
(Map.toList (Consensus.supportedNodeToClientVersions proxy))
Expand Down
33 changes: 20 additions & 13 deletions cardano-cli/src/Cardano/CLI/Ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,26 @@ maybeUnixSockEndPoint = \case
UnixSockEndPoint sock -> Just sock

data PingCmd = PingCmd
{ pingCmdCount :: !Word32
, pingCmdEndPoint :: !EndPoint
, pingCmdPort :: !String
, pingCmdMagic :: !Word32
, pingCmdJson :: !Bool
, pingCmdQuiet :: !Bool
{ pingCmdCount :: !Word32
, pingCmdEndPoint :: !EndPoint
, pingCmdPort :: !String
, pingCmdMagic :: !Word32
, pingCmdJson :: !Bool
, pingCmdQuiet :: !Bool
, pingOptsHandshakeQuery :: !Bool
} deriving (Eq, Show)

pingClient :: Tracer IO CNP.LogMsg -> Tracer IO String -> PingCmd -> [CNP.NodeVersion] -> AddrInfo -> IO ()
pingClient stdout stderr cmd = CNP.pingClient stdout stderr opts
where opts = CNP.PingOpts
{ CNP.pingOptsQuiet = pingCmdQuiet cmd
, CNP.pingOptsJson = pingCmdJson cmd
, CNP.pingOptsCount = pingCmdCount cmd
, CNP.pingOptsHost = maybeHostEndPoint (pingCmdEndPoint cmd)
, CNP.pingOptsUnixSock = maybeUnixSockEndPoint (pingCmdEndPoint cmd)
, CNP.pingOptsPort = pingCmdPort cmd
, CNP.pingOptsMagic = pingCmdMagic cmd
{ CNP.pingOptsQuiet = pingCmdQuiet cmd
, CNP.pingOptsJson = pingCmdJson cmd
, CNP.pingOptsCount = pingCmdCount cmd
, CNP.pingOptsHost = maybeHostEndPoint (pingCmdEndPoint cmd)
, CNP.pingOptsUnixSock = maybeUnixSockEndPoint (pingCmdEndPoint cmd)
, CNP.pingOptsPort = pingCmdPort cmd
, CNP.pingOptsMagic = pingCmdMagic cmd
, CNP.pingOptsHandshakeQuery = pingOptsHandshakeQuery cmd
}

runPingCmd :: PingCmd -> ExceptT PingClientCmdError IO ()
Expand Down Expand Up @@ -196,3 +198,8 @@ pPing = PingCmd
, Opt.help "Quiet flag, CSV/JSON only output"
]
)
<*> ( Opt.switch $ mconcat
[ Opt.long "query-versions"
, Opt.help "Query the supported protocol versions during the handshake and terminate the connection."
]
)
8 changes: 4 additions & 4 deletions trace-dispatcher/src/Cardano/Logging/Forwarding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import Ouroboros.Network.Protocol.Handshake.Codec (cborTermVersionData
codecHandshake, noTimeLimitsHandshake)
import Ouroboros.Network.Protocol.Handshake.Type (Handshake)
import Ouroboros.Network.Protocol.Handshake.Version (acceptableVersion,
simpleSingletonVersions)
queryVersion, simpleSingletonVersions)
import Ouroboros.Network.Snocket (Snocket, MakeBearer, localAddressFromPath, localSnocket,
makeLocalBearer)
import Ouroboros.Network.Socket (AcceptedConnectionsLimit (..),
import Ouroboros.Network.Socket (AcceptedConnectionsLimit (..), HandshakeCallbacks (..),
SomeResponderApplication (..), cleanNetworkMutableState, connectToNode,
newNetworkMutableState, nullNetworkConnectTracers, nullNetworkServerTracers,
withServerNode)
Expand Down Expand Up @@ -187,7 +187,7 @@ doConnectToAcceptor magic snocket makeBearer configureSocket address timeLimits
timeLimits
(cborTermVersionDataCodec forwardingCodecCBORTerm)
nullNetworkConnectTracers
acceptableVersion
(HandshakeCallbacks acceptableVersion queryVersion)
(simpleSingletonVersions
ForwardingV_1
(ForwardingVersionData magic)
Expand Down Expand Up @@ -248,7 +248,7 @@ doListenToAcceptor magic snocket makeBearer configureSocket address timeLimits
(codecHandshake forwardingVersionCodec)
timeLimits
(cborTermVersionDataCodec forwardingCodecCBORTerm)
acceptableVersion
(HandshakeCallbacks acceptableVersion queryVersion)
(simpleSingletonVersions
ForwardingV_1
(ForwardingVersionData magic)
Expand Down
5 changes: 4 additions & 1 deletion trace-dispatcher/src/Cardano/Logging/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import qualified Codec.CBOR.Term as CBOR

import Ouroboros.Network.CodecCBORTerm
import Ouroboros.Network.Magic
import Ouroboros.Network.Protocol.Handshake.Version (Accept (..), Acceptable (..))
import Ouroboros.Network.Protocol.Handshake.Version (Accept (..), Acceptable (..), Queryable (..))

data ForwardingVersion
= ForwardingV_1
Expand Down Expand Up @@ -49,6 +49,9 @@ instance Acceptable ForwardingVersionData where
++ show local
++ " /= " ++ show remote

instance Queryable ForwardingVersionData where
queryVersion _ = False

forwardingCodecCBORTerm :: ForwardingVersion -> CodecCBORTerm Text ForwardingVersionData
forwardingCodecCBORTerm _ = CodecCBORTerm { encodeTerm, decodeTerm }
where
Expand Down

0 comments on commit ab09b2e

Please sign in to comment.