diff --git a/cabal.project b/cabal.project index 1a927bf6eaf..19d0079e880 100644 --- a/cabal.project +++ b/cabal.project @@ -68,3 +68,12 @@ allow-newer: -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. + +source-repository-package + type: git + location: https://github.com/IntersectMBO/ouroboros-network + tag: e8896feaf2ffb9758d27c00d842237e2dbd56592 + --sha256: sha256-78ulTpgwJuccs3ntjHebkIyrdT7Id572fk0xwianOe0= + subdir: network-mux + ouroboros-network-framework + ouroboros-network diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs index 316c9122369..60c02c64275 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs @@ -28,6 +28,7 @@ import Ouroboros.Network.ConnectionHandler (ConnectionHandlerTrace (.. import Ouroboros.Network.ConnectionId (ConnectionId (..)) import Ouroboros.Network.ConnectionManager.Types (ConnectionManagerCounters (..), ConnectionManagerTrace (..)) +import Ouroboros.Network.ConnectionManager.ConnMap (ConnMap (..)) import qualified Ouroboros.Network.ConnectionManager.Types as ConnectionManager import Ouroboros.Network.InboundGovernor (InboundGovernorTrace (..)) import qualified Ouroboros.Network.InboundGovernor as InboundGovernor @@ -1132,6 +1133,10 @@ instance Show lAddr => LogFormatting (PeerSelectionActionsTrace SockAddr lAddr) , "connectionId" .= toJSON connId , "withProtocolTemp" .= show wf ] + forMachine _dtal (AcquireConnectionError err) = + mconcat [ "kind" .= String "AcquireConnectionError" + , "error" .= show err + ] forHuman = pack . show instance MetaTrace (PeerSelectionActionsTrace SockAddr lAddr) where @@ -1139,6 +1144,7 @@ instance MetaTrace (PeerSelectionActionsTrace SockAddr lAddr) where namespaceFor PeerStatusChangeFailure {} = Namespace [] ["StatusChangeFailure"] namespaceFor PeerMonitoringError {} = Namespace [] ["MonitoringError"] namespaceFor PeerMonitoringResult {} = Namespace [] ["MonitoringResult"] + namespaceFor AcquireConnectionError {} = Namespace [] ["AcquireConnectionError"] severityFor (Namespace _ ["StatusChanged"]) _ = Just Info severityFor (Namespace _ ["StatusChangeFailure"]) _ = Just Error @@ -1176,10 +1182,10 @@ instance (Show addr, Show versionNumber, Show agreedOptions, LogFormatting addr, , "remoteAddress" .= forMachine dtal peerAddr , "provenance" .= String (pack . show $ prov) ] - forMachine dtal (TrUnregisterConnection prov peerAddr) = + forMachine _dtal (TrUnregisterConnection prov connId) = mconcat $ reverse [ "kind" .= String "UnregisterConnection" - , "remoteAddress" .= forMachine dtal peerAddr + , "remoteAddress" .= toJSON connId , "provenance" .= String (pack . show $ prov) ] forMachine _dtal (TrConnect (Just localAddress) remoteAddress) = @@ -1255,12 +1261,12 @@ instance (Show addr, Show versionNumber, Show agreedOptions, LogFormatting addr, , "remoteAddress" .= forMachine dtal remoteAddress , "connectionState" .= toJSON connState ] - forMachine dtal (TrPruneConnections pruningSet numberPruned chosenPeers) = + forMachine _dtal (TrPruneConnections pruningSet numberPruned chosenPeers) = mconcat [ "kind" .= String "PruneConnections" , "prunedPeers" .= toJSON pruningSet , "numberPrunedPeers" .= toJSON numberPruned - , "choiceSet" .= toJSON (forMachine dtal `Set.map` chosenPeers) + , "choiceSet" .= toJSON (toJSON `Set.map` chosenPeers) ] forMachine _dtal (TrConnectionCleanup connId) = mconcat @@ -1285,12 +1291,20 @@ instance (Show addr, Show versionNumber, Show agreedOptions, LogFormatting addr, forMachine _dtal (TrState cmState) = mconcat [ "kind" .= String "ConnectionManagerState" - , "state" .= listValue (\(addr, connState) -> + , "state" .= listValue (\(remoteAddr, inner) -> object - [ "remoteAddress" .= toJSON addr - , "connectionState" .= toJSON connState - ]) - (Map.toList cmState) + [ "connections" .= + listValue (\(localAddr, connState) -> + object + [ "localAddress" .= localAddr + , "state" .= toJSON connState + ] + ) + (Map.toList inner) + , "remoteAddress" .= toJSON remoteAddr + ] + ) + (Map.toList (getConnMap cmState)) ] forMachine _dtal (ConnectionManager.TrUnexpectedlyFalseAssertion info) = mconcat @@ -1497,9 +1511,9 @@ instance MetaTrace (ConnectionManager.AbstractTransitionTrace peerAddr) where instance (Show addr, LogFormatting addr, ToJSON addr) => LogFormatting (ServerTrace addr) where - forMachine dtal (TrAcceptConnection peerAddr) = + forMachine _dtal (TrAcceptConnection connId) = mconcat [ "kind" .= String "AcceptConnection" - , "address" .= forMachine dtal peerAddr + , "address" .= toJSON connId ] forMachine _dtal (TrAcceptError exception) = mconcat [ "kind" .= String "AcceptErroor" diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs index 5ca65ab077a..333a4a0162a 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs @@ -41,6 +41,7 @@ import qualified Ouroboros.Network.BlockFetch.ClientState as BlockFetch import Ouroboros.Network.BlockFetch.Decision (FetchDecision, FetchDecline (..)) import Ouroboros.Network.ConnectionHandler (ConnectionHandlerTrace (..)) import Ouroboros.Network.ConnectionId (ConnectionId (..)) +import Ouroboros.Network.ConnectionManager.ConnMap (ConnMap (..), LocalAddr (..)) import Ouroboros.Network.ConnectionManager.Types (AbstractState (..), ConnectionManagerCounters (..), ConnectionManagerTrace (..), OperationResult (..)) @@ -496,6 +497,7 @@ instance HasSeverityAnnotation (PeerSelectionActionsTrace SockAddr lAddr) where PeerStatusChangeFailure {} -> Error PeerMonitoringError {} -> Error PeerMonitoringResult {} -> Debug + AcquireConnectionError {} -> Info instance HasPrivacyAnnotation PeerSelectionCounters instance HasSeverityAnnotation PeerSelectionCounters where @@ -2059,6 +2061,10 @@ instance Show lAddr => ToObject (PeerSelectionActionsTrace SockAddr lAddr) where , "connectionId" .= toJSON connId , "withProtocolTemp" .= show wf ] + toObject _verb (AcquireConnectionError err) = + mconcat [ "kind" .= String "AcquireConnectionError" + , "error" .= show err + ] instance ToObject PeerSelectionCounters where toObject _verb PeerSelectionCounters {..} = @@ -2255,6 +2261,10 @@ instance (Show versionNumber, ToJSON versionNumber, ToJSON agreedOptions) , "command" .= show cerr ] +instance ToJSON addr => ToJSON (LocalAddr addr) where + toJSON (LocalAddr addr) = toJSON addr + toJSON UnknownLocalAddr = Null + instance (Show addr, Show versionNumber, Show agreedOptions, ToObject addr, ToJSON addr, ToJSON versionNumber, ToJSON agreedOptions) => ToObject (ConnectionManagerTrace addr (ConnectionHandlerTrace versionNumber agreedOptions)) where @@ -2266,10 +2276,10 @@ instance (Show addr, Show versionNumber, Show agreedOptions, ToObject addr, , "remoteAddress" .= toObject verb peerAddr , "provenance" .= String (pack . show $ prov) ] - TrUnregisterConnection prov peerAddr -> + TrUnregisterConnection prov connId -> mconcat $ reverse [ "kind" .= String "UnregisterConnection" - , "remoteAddress" .= toObject verb peerAddr + , "remoteAddress" .= toJSON connId , "provenance" .= String (pack . show $ prov) ] TrConnect (Just localAddress) remoteAddress -> @@ -2350,7 +2360,7 @@ instance (Show addr, Show versionNumber, Show agreedOptions, ToObject addr, [ "kind" .= String "PruneConnections" , "prunedPeers" .= toJSON pruningSet , "numberPrunedPeers" .= toJSON numberPruned - , "choiceSet" .= toJSON (toObject verb `Set.map` chosenPeers) + , "choiceSet" .= toJSON (toJSON `Set.map` chosenPeers) ] TrConnectionCleanup connId -> mconcat @@ -2375,12 +2385,20 @@ instance (Show addr, Show versionNumber, Show agreedOptions, ToObject addr, TrState cmState -> mconcat [ "kind" .= String "ConnectionManagerState" - , "state" .= listValue (\(addr, connState) -> + , "state" .= listValue (\(remoteAddr, inner) -> Aeson.object - [ "remoteAddress" .= toJSON addr - , "connectionState" .= toJSON connState - ]) - (Map.toList cmState) + [ "connections" .= + listValue (\(localAddr, connState) -> + Aeson.object + [ "localAddress" .= localAddr + , "state" .= toJSON connState + ] + ) + (Map.toList inner) + , "remoteAddress" .= toJSON remoteAddr + ] + ) + (Map.toList (getConnMap cmState)) ] ConnMgr.TrUnexpectedlyFalseAssertion info -> mconcat @@ -2415,9 +2433,9 @@ instance (Show addr, ToObject addr, ToJSON addr) instance (Show addr, ToObject addr, ToJSON addr) => ToObject (ServerTrace addr) where - toObject verb (TrAcceptConnection peerAddr) = + toObject _verb (TrAcceptConnection connId) = mconcat [ "kind" .= String "AcceptConnection" - , "address" .= toObject verb peerAddr + , "connectionId" .= toJSON connId ] toObject _verb (TrAcceptError exception) = mconcat [ "kind" .= String "AcceptErroor"