Skip to content

Commit

Permalink
Split WarningDevelopmentNetworkProtocolVersions
Browse files Browse the repository at this point in the history
Split it into node-to-node and node-to-client. This is needed so that the
log contains information whether the version numbers (now encoded as
numbers) are node-to-node or node-to-client version.
  • Loading branch information
coot committed Jan 19, 2023
1 parent 8d53ce6 commit 489d871
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 20 deletions.
11 changes: 8 additions & 3 deletions cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,15 @@ handleSimpleNode runP p2pMode tracers nc onKernel = do
(_, Nothing) -> Map.keys
$ supportedNodeToClientVersions (Proxy @blk)
when ( ncTestEnableDevelopmentNetworkProtocols nc
&& (not (null developmentNtnVersions) || not (null developmentNtcVersions)) )
&& not (null developmentNtnVersions))
$ traceWith (startupTracer tracers)
(WarningDevelopmentNetworkProtocols
developmentNtnVersions
(WarningDevelopmentNodeToNodeVersions
developmentNtnVersions)

when ( ncTestEnableDevelopmentNetworkProtocols nc
&& not (null developmentNtcVersions))
$ traceWith (startupTracer tracers)
(WarningDevelopmentNodeToClientVersions
developmentNtcVersions)

#ifdef UNIX
Expand Down
13 changes: 10 additions & 3 deletions cardano-node/src/Cardano/Node/Startup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,15 @@ data StartupTrace blk =
--
| P2PWarningDevelopementNetworkProtocols

-- | Warn when 'TestEnableDevelopmentNetworkProtocols' is set.
-- | Warn when 'TestEnableDevelopmentNetworkProtocols' is set and affects
-- node-to-node protocol.
--
| WarningDevelopmentNetworkProtocols [NodeToNodeVersion] [NodeToClientVersion]
| WarningDevelopmentNodeToNodeVersions [NodeToNodeVersion]

-- | Warn when 'TestEnableDevelopmentNetworkProtocols' is set and affects
-- node-to-client protocol.
--
| WarningDevelopmentNodeToClientVersions [NodeToClientVersion]

| BICommon BasicInfoCommon
| BIShelley BasicInfoShelleyBased
Expand All @@ -124,7 +130,8 @@ severityStartupTracer (NetworkConfigUpdateError _) = Error
severityStartupTracer NetworkConfigUpdateUnsupported = Warning
severityStartupTracer P2PWarning = Warning
severityStartupTracer P2PWarningDevelopementNetworkProtocols = Warning
severityStartupTracer WarningDevelopmentNetworkProtocols {} = Warning
severityStartupTracer WarningDevelopmentNodeToNodeVersions {} = Warning
severityStartupTracer WarningDevelopmentNodeToClientVersions {} = Warning
severityStartupTracer _ = Info

data BasicInfoCommon = BasicInfoCommon {
Expand Down
12 changes: 7 additions & 5 deletions cardano-node/src/Cardano/Node/Tracing/StateRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ data StartupState
| NetworkConfigUpdateError Text
| P2PWarning
| P2PWarningDevelopementNetworkProtocols
| WarningDevelopmentNetworkProtocols [NPV.NodeToNodeVersion] [NPV.NodeToClientVersion]
| WarningDevelopmentNodeToNodeVersions [NPV.NodeToNodeVersion]
| WarningDevelopmentNodeToClientVersions [NPV.NodeToClientVersion]
deriving (Generic, FromJSON, ToJSON)

-- | The representation of the current state of node.
Expand Down Expand Up @@ -216,10 +217,11 @@ traceNodeStateStartup tr ev =
traceWith tr $ NodeStartup $ NetworkConfigUpdateError e
Startup.P2PWarning ->
traceWith tr $ NodeStartup P2PWarning
Startup.P2PWarningDevelopementNetworkProtocols ->
traceWith tr $ NodeStartup P2PWarningDevelopementNetworkProtocols
Startup.WarningDevelopmentNetworkProtocols n2ns n2cs ->
traceWith tr $ NodeStartup $ WarningDevelopmentNetworkProtocols n2ns n2cs
Startup.WarningDevelopmentNodeToNodeVersions ntnVersions ->
traceWith tr $ NodeStartup (WarningDevelopmentNodeToNodeVersions ntnVersions)
Startup.WarningDevelopmentNodeToClientVersions ntcVersions ->
traceWith tr $ NodeStartup (WarningDevelopmentNodeToClientVersions ntcVersions)
-- TODO: why other constructors are not traced?
_ -> return ()

traceNodeStateShutdown
Expand Down
23 changes: 15 additions & 8 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ namesStartupInfo = \case
NetworkConfigLegacy {} -> ["NetworkConfigLegacy"]
P2PWarning {} -> ["P2PWarning"]
P2PWarningDevelopementNetworkProtocols {} -> ["P2PWarningDevelopementNetworkProtocols"]
WarningDevelopmentNetworkProtocols {} -> ["WarningDevelopmentNetworkProtocols"]
WarningDevelopmentNodeToNodeVersions {} -> ["WarningDevelopmentNodeToNodeVersions"]
WarningDevelopmentNodeToClientVersions {} -> ["WarningDevelopmentNodeToClientVersions"]
BICommon {} -> ["Common"]
BIShelley {} -> ["ShelleyBased"]
BIByron {} -> ["Byron"]
Expand Down Expand Up @@ -245,11 +246,15 @@ instance ( Show (BlockNodeToNodeVersion blk)
forMachine _dtal P2PWarningDevelopementNetworkProtocols =
mconcat [ "kind" .= String "P2PWarningDevelopementNetworkProtocols"
, "message" .= String p2pWarningDevelopmentNetworkProtocolsMessage ]
forMachine _ver (WarningDevelopmentNetworkProtocols ntnVersions ntcVersions) =
mconcat [ "kind" .= String "WarningDevelopmentNetworkProtocols"
forMachine _ver (WarningDevelopmentNodeToNodeVersions ntnVersions) =
mconcat [ "kind" .= String "WarningDevelopmentNodeToNodeVersions"
, "message" .= String "enabled development network protocols"
, "nodeToNodeDevelopmentVersions" .= String (showT ntnVersions)
, "nodeToClientDevelopmentVersions" .= String (showT ntcVersions)
, "versions" .= String (showT ntnVersions)
]
forMachine _ver (WarningDevelopmentNodeToClientVersions ntcVersions) =
mconcat [ "kind" .= String "WarningDevelopmentNodeToClientVersions"
, "message" .= String "enabled development network protocols"
, "versions" .= String (showT ntcVersions)
]
forMachine _dtal (BINetwork BasicInfoNetwork {..}) =
mconcat [ "kind" .= String "BasicInfoNetwork"
Expand Down Expand Up @@ -353,10 +358,12 @@ ppStartupInfoTrace P2PWarning = p2pWarningMessage
ppStartupInfoTrace P2PWarningDevelopementNetworkProtocols =
p2pWarningDevelopmentNetworkProtocolsMessage

ppStartupInfoTrace (WarningDevelopmentNetworkProtocols ntnVersions ntcVersions) =
"enabled development network protocols: "
ppStartupInfoTrace (WarningDevelopmentNodeToNodeVersions ntnVersions) =
"enabled development node-to-node versions: "
<> showT ntnVersions
<> " "

ppStartupInfoTrace (WarningDevelopmentNodeToClientVersions ntcVersions) =
"enabled development node-to-client versions: "
<> showT ntcVersions

ppStartupInfoTrace (BINetwork BasicInfoNetwork {..}) =
Expand Down
3 changes: 2 additions & 1 deletion cardano-node/src/Cardano/Tracing/Startup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ instance HasSeverityAnnotation (StartupTrace blk) where
getSeverityAnnotation NetworkConfigUpdateUnsupported = Warning
getSeverityAnnotation P2PWarning = Warning
getSeverityAnnotation P2PWarningDevelopementNetworkProtocols = Warning
getSeverityAnnotation WarningDevelopmentNetworkProtocols {} = Warning
getSeverityAnnotation WarningDevelopmentNodeToNodeVersions {} = Warning
getSeverityAnnotation WarningDevelopmentNodeToClientVersions {} = Warning
getSeverityAnnotation _ = Info

instance HasPrivacyAnnotation (StartupTrace blk)
Expand Down

0 comments on commit 489d871

Please sign in to comment.