@@ -80,6 +80,11 @@ import qualified Data.Text as Text
8080import Data.Time (NominalDiffTime )
8181import Data.Word (Word32 , Word64 )
8282import Network.TypedProtocol.Core
83+ import Network.TypedProtocol.Codec (AnyMessage (AnyMessageAndAgency ))
84+ import Ouroboros.Consensus.MiniProtocol.ObjectDiffusion.PerasCert
85+ import Ouroboros.Consensus.MiniProtocol.ObjectDiffusion.Inbound (TraceObjectDiffusionInbound (.. ), NumObjectsProcessed (.. ))
86+ import Ouroboros.Consensus.MiniProtocol.ObjectDiffusion.Outbound (TraceObjectDiffusionOutbound (.. ))
87+ import Ouroboros.Network.Protocol.ObjectDiffusion.Type (NumObjectIdsReq (.. ), NumObjectIdsAck (.. ), ObjectDiffusion (.. ), Message (.. ), BlockingReplyList (.. ))
8388
8489
8590instance (LogFormatting adr , Show adr ) => LogFormatting (ConnectionId adr ) where
@@ -1428,6 +1433,279 @@ instance MetaTrace (TraceEventMempool blk) where
14281433 , Namespace [] [" LedgerFound" ]
14291434 ]
14301435
1436+ --------------------------------------------------------------------------------
1437+ -- PerasCertDiffusionInbound Tracer
1438+ --------------------------------------------------------------------------------
1439+
1440+ instance MetaTrace (TracePerasCertDiffusionInbound blk ) where
1441+ namespaceFor TraceObjectDiffusionCollected {} =
1442+ Namespace [] [" Collected" ]
1443+ namespaceFor TraceObjectDiffusionProcessed {} =
1444+ Namespace [] [" Processed" ]
1445+ namespaceFor TraceObjectDiffusionControlMessage {} =
1446+ Namespace [] [" ControlMessage" ]
1447+ namespaceFor TraceObjectInboundCanRequestMoreObjects {} =
1448+ Namespace [] [" CanRequestMoreObjects" ]
1449+ namespaceFor TraceObjectInboundCannotRequestMoreObjects {} =
1450+ Namespace [] [" CannotRequestMoreObjects" ]
1451+
1452+ severityFor (Namespace _ [" Collected" ]) _ = Just Info
1453+ severityFor (Namespace _ [" Processed" ]) _ = Just Info
1454+ severityFor (Namespace _ [" ControlMessage" ]) _ = Just Info
1455+ severityFor (Namespace _ [" CanRequestMoreObjects" ]) _ = Just Info
1456+ severityFor (Namespace _ [" CannotRequestMoreObjects" ]) _ = Just Info
1457+ severityFor _ _ = Nothing
1458+
1459+ documentFor (Namespace _ [" Collected" ]) = Just
1460+ " Objects have been collected from the peer."
1461+ documentFor (Namespace _ [" Processed" ]) = Just
1462+ " Objects have been processed and added to the pool."
1463+ documentFor (Namespace _ [" ControlMessage" ]) = Just
1464+ " A control message has been received."
1465+ documentFor (Namespace _ [" CanRequestMoreObjects" ]) = Just
1466+ " More objects can be requested from the peer."
1467+ documentFor (Namespace _ [" CannotRequestMoreObjects" ]) = Just
1468+ " No more objects can be requested from the peer at this time."
1469+ documentFor _ = Nothing
1470+
1471+ allNamespaces =
1472+ [ Namespace [] [" Collected" ]
1473+ , Namespace [] [" Processed" ]
1474+ , Namespace [] [" ControlMessage" ]
1475+ , Namespace [] [" CanRequestMoreObjects" ]
1476+ , Namespace [] [" CannotRequestMoreObjects" ]
1477+ ]
1478+
1479+ --------------------------------------------------------------------------------
1480+ -- PerasCertDiffusionInbound LogFormatting
1481+ --------------------------------------------------------------------------------
1482+
1483+ instance LogFormatting (TracePerasCertDiffusionInbound blk ) where
1484+ forMachine _dtal = \ case
1485+ TraceObjectDiffusionCollected n ->
1486+ mconcat
1487+ [ " kind" .= String " Collected"
1488+ , " count" .= n
1489+ ]
1490+ TraceObjectDiffusionProcessed (NumObjectsProcessed n) ->
1491+ mconcat
1492+ [ " kind" .= String " Processed"
1493+ , " count" .= n
1494+ ]
1495+ TraceObjectDiffusionControlMessage msg ->
1496+ mconcat
1497+ [ " kind" .= String " ControlMessage"
1498+ , " message" .= String (Text. pack $ show msg)
1499+ ]
1500+ TraceObjectInboundCanRequestMoreObjects {} ->
1501+ mconcat
1502+ [ " kind" .= String " CanRequestMoreObjects"
1503+ ]
1504+ TraceObjectInboundCannotRequestMoreObjects {} ->
1505+ mconcat
1506+ [ " kind" .= String " CannotRequestMoreObjects"
1507+ ]
1508+
1509+ forHuman = \ case
1510+ TraceObjectDiffusionCollected n ->
1511+ " Collected " <> showT n <> " Peras certificates"
1512+ TraceObjectDiffusionProcessed n ->
1513+ " Processed " <> showT n <> " Peras certificates"
1514+ TraceObjectDiffusionControlMessage msg ->
1515+ " Received control message: " <> showT msg
1516+ TraceObjectInboundCanRequestMoreObjects {} ->
1517+ " Can request more Peras certificates from peer"
1518+ TraceObjectInboundCannotRequestMoreObjects {} ->
1519+ " Cannot request more Peras certificates from peer at this time"
1520+
1521+ --------------------------------------------------------------------------------
1522+ -- PerasCertDiffusionOutbound Tracer
1523+ --------------------------------------------------------------------------------
1524+
1525+ instance MetaTrace (TracePerasCertDiffusionOutbound blk ) where
1526+ namespaceFor TraceObjectDiffusionOutboundTerminated {} =
1527+ Namespace [] [" Terminated" ]
1528+ namespaceFor TraceObjectDiffusionOutboundRecvMsgRequestObjectIds {} =
1529+ Namespace [] [" RecvMsgRequestObjectIds" ]
1530+ namespaceFor TraceObjectDiffusionOutboundSendMsgReplyObjectIds {} =
1531+ Namespace [] [" SendMsgReplyObjectIds" ]
1532+ namespaceFor TraceObjectDiffusionOutboundRecvMsgRequestObjects {} =
1533+ Namespace [] [" RecvMsgRequestObjects" ]
1534+ namespaceFor TraceObjectDiffusionOutboundSendMsgReplyObjects {} =
1535+ Namespace [] [" SendMsgReplyObjects" ]
1536+
1537+ severityFor (Namespace _ [" Terminated" ]) _ = Just Info
1538+ severityFor (Namespace _ [" RecvMsgRequestObjectIds" ]) _ = Just Info
1539+ severityFor (Namespace _ [" SendMsgReplyObjectIds" ]) _ = Just Info
1540+ severityFor (Namespace _ [" RecvMsgRequestObjects" ]) _ = Just Info
1541+ severityFor (Namespace _ [" SendMsgReplyObjects" ]) _ = Just Info
1542+ severityFor _ _ = Nothing
1543+
1544+ documentFor (Namespace _ [" Terminated" ]) = Just
1545+ " The object diffusion mini-protocol has been terminated by the inbound peer."
1546+ documentFor (Namespace _ [" RecvMsgRequestObjectIds" ]) = Just
1547+ " Received a request for object IDs from the inbound peer."
1548+ documentFor (Namespace _ [" SendMsgReplyObjectIds" ]) = Just
1549+ " Sending a reply with object IDs to the inbound peer."
1550+ documentFor (Namespace _ [" RecvMsgRequestObjects" ]) = Just
1551+ " Received a request for specific objects from the inbound peer."
1552+ documentFor (Namespace _ [" SendMsgReplyObjects" ]) = Just
1553+ " Sending a reply with specific objects to the inbound peer."
1554+ documentFor _ = Nothing
1555+
1556+ allNamespaces =
1557+ [ Namespace [] [" Terminated" ]
1558+ , Namespace [] [" RecvMsgRequestObjectIds" ]
1559+ , Namespace [] [" SendMsgReplyObjectIds" ]
1560+ , Namespace [] [" RecvMsgRequestObjects" ]
1561+ , Namespace [] [" SendMsgReplyObjects" ]
1562+ ]
1563+
1564+ --------------------------------------------------------------------------------
1565+ -- PerasCertDiffusionOutbound LogFormatting
1566+ --------------------------------------------------------------------------------
1567+
1568+ instance LogFormatting (TracePerasCertDiffusionOutbound blk ) where
1569+ forMachine _dtal = \ case
1570+ TraceObjectDiffusionOutboundTerminated ->
1571+ mconcat
1572+ [ " kind" .= String " Terminated"
1573+ ]
1574+ TraceObjectDiffusionOutboundRecvMsgRequestObjectIds (NumObjectIdsReq n) ->
1575+ mconcat
1576+ [ " kind" .= String " RecvMsgRequestObjectIds"
1577+ , " count" .= n
1578+ ]
1579+ TraceObjectDiffusionOutboundSendMsgReplyObjectIds roundNos ->
1580+ mconcat
1581+ [ " kind" .= String " SendMsgReplyObjectIds"
1582+ , " count" .= length roundNos
1583+ ]
1584+ TraceObjectDiffusionOutboundRecvMsgRequestObjects objIds ->
1585+ mconcat
1586+ [ " kind" .= String " RecvMsgRequestObjects"
1587+ , " count" .= length objIds
1588+ ]
1589+ TraceObjectDiffusionOutboundSendMsgReplyObjects objs ->
1590+ mconcat
1591+ [ " kind" .= String " SendMsgReplyObjects"
1592+ , " count" .= length objs
1593+ ]
1594+
1595+ forHuman = \ case
1596+ TraceObjectDiffusionOutboundTerminated ->
1597+ " Peras certificate diffusion mini-protocol has been terminated"
1598+ TraceObjectDiffusionOutboundRecvMsgRequestObjectIds n ->
1599+ " Received request for " <> showT n <> " Peras certificate IDs"
1600+ TraceObjectDiffusionOutboundSendMsgReplyObjectIds roundNos ->
1601+ " Sending " <> showT (length roundNos) <> " Peras certificate IDs"
1602+ TraceObjectDiffusionOutboundRecvMsgRequestObjects objIds ->
1603+ " Received request for " <> showT (length objIds) <> " Peras certificates"
1604+ TraceObjectDiffusionOutboundSendMsgReplyObjects objs ->
1605+ " Sending " <> showT (length objs) <> " Peras certificates to inbound peer"
1606+
1607+
1608+
1609+ --------------------------------------------------------------------------------
1610+ -- ObjectDiffusion Protocol Tracer (AnyMessage)
1611+ --------------------------------------------------------------------------------
1612+
1613+ instance LogFormatting (AnyMessage (ObjectDiffusion objectId object )) where
1614+ forMachine _dtal (AnyMessageAndAgency _stok MsgInit ) =
1615+ mconcat
1616+ [ " kind" .= String " MsgInit"
1617+ ]
1618+ forMachine _dtal (AnyMessageAndAgency _stok (MsgRequestObjectIds _ ack req)) =
1619+ mconcat
1620+ [ " kind" .= String " MsgRequestObjectIds"
1621+ , " ack" .= getNumObjectIdsAck ack
1622+ , " req" .= getNumObjectIdsReq req
1623+ ]
1624+ forMachine _dtal (AnyMessageAndAgency _stok (MsgReplyObjectIds objIds)) =
1625+ let count = case objIds of
1626+ BlockingReply xs -> length xs
1627+ NonBlockingReply xs -> length xs
1628+ in mconcat
1629+ [ " kind" .= String " MsgReplyObjectIds"
1630+ , " count" .= (count :: Int )
1631+ ]
1632+ forMachine _dtal (AnyMessageAndAgency _stok (MsgRequestObjects objIds)) =
1633+ mconcat
1634+ [ " kind" .= String " MsgRequestObjects"
1635+ , " count" .= length objIds
1636+ ]
1637+ forMachine _dtal (AnyMessageAndAgency _stok (MsgReplyObjects objects)) =
1638+ mconcat
1639+ [ " kind" .= String " MsgReplyObjects"
1640+ , " count" .= length objects
1641+ ]
1642+ forMachine _dtal (AnyMessageAndAgency _stok MsgDone ) =
1643+ mconcat
1644+ [ " kind" .= String " MsgDone"
1645+ ]
1646+
1647+ forHuman (AnyMessageAndAgency _stok MsgInit ) =
1648+ " ObjectDiffusion protocol initialized"
1649+ forHuman (AnyMessageAndAgency _stok (MsgRequestObjectIds _ ack req)) =
1650+ " Requested " <> showT (getNumObjectIdsReq req) <> " object IDs, acknowledging " <> showT (getNumObjectIdsAck ack)
1651+ forHuman (AnyMessageAndAgency _stok (MsgReplyObjectIds objIds)) =
1652+ let count = case objIds of
1653+ BlockingReply xs -> length xs
1654+ NonBlockingReply xs -> length xs
1655+ in " Replied with " <> showT (count :: Int ) <> " object IDs"
1656+ forHuman (AnyMessageAndAgency _stok (MsgRequestObjects objIds)) =
1657+ " Requested " <> showT (length objIds) <> " objects"
1658+ forHuman (AnyMessageAndAgency _stok (MsgReplyObjects objects)) =
1659+ " Replied with " <> showT (length objects) <> " objects"
1660+ forHuman (AnyMessageAndAgency _stok MsgDone ) =
1661+ " ObjectDiffusion protocol terminated"
1662+
1663+ instance MetaTrace (AnyMessage (ObjectDiffusion objectId object )) where
1664+ namespaceFor (AnyMessageAndAgency _stok MsgInit ) =
1665+ Namespace [] [" MsgInit" ]
1666+ namespaceFor (AnyMessageAndAgency _stok (MsgRequestObjectIds _ _ _)) =
1667+ Namespace [] [" MsgRequestObjectIds" ]
1668+ namespaceFor (AnyMessageAndAgency _stok (MsgReplyObjectIds _)) =
1669+ Namespace [] [" MsgReplyObjectIds" ]
1670+ namespaceFor (AnyMessageAndAgency _stok (MsgRequestObjects _)) =
1671+ Namespace [] [" MsgRequestObjects" ]
1672+ namespaceFor (AnyMessageAndAgency _stok (MsgReplyObjects _)) =
1673+ Namespace [] [" MsgReplyObjects" ]
1674+ namespaceFor (AnyMessageAndAgency _stok MsgDone ) =
1675+ Namespace [] [" MsgDone" ]
1676+
1677+ severityFor (Namespace _ [" MsgInit" ]) _ = Just Info
1678+ severityFor (Namespace _ [" MsgRequestObjectIds" ]) _ = Just Debug
1679+ severityFor (Namespace _ [" MsgReplyObjectIds" ]) _ = Just Debug
1680+ severityFor (Namespace _ [" MsgRequestObjects" ]) _ = Just Debug
1681+ severityFor (Namespace _ [" MsgReplyObjects" ]) _ = Just Debug
1682+ severityFor (Namespace _ [" MsgDone" ]) _ = Just Info
1683+ severityFor _ _ = Nothing
1684+
1685+ documentFor (Namespace _ [" MsgInit" ]) = Just
1686+ " ObjectDiffusion protocol initialization message."
1687+ documentFor (Namespace _ [" MsgRequestObjectIds" ]) = Just
1688+ " Request for object identifiers with acknowledgement count."
1689+ documentFor (Namespace _ [" MsgReplyObjectIds" ]) = Just
1690+ " Reply with available object identifiers."
1691+ documentFor (Namespace _ [" MsgRequestObjects" ]) = Just
1692+ " Request for specific objects by their identifiers."
1693+ documentFor (Namespace _ [" MsgReplyObjects" ]) = Just
1694+ " Reply with the requested objects."
1695+ documentFor (Namespace _ [" MsgDone" ]) = Just
1696+ " ObjectDiffusion protocol termination message."
1697+ documentFor _ = Nothing
1698+
1699+ allNamespaces =
1700+ [ Namespace [] [" MsgInit" ]
1701+ , Namespace [] [" MsgRequestObjectIds" ]
1702+ , Namespace [] [" MsgReplyObjectIds" ]
1703+ , Namespace [] [" MsgRequestObjects" ]
1704+ , Namespace [] [" MsgReplyObjects" ]
1705+ , Namespace [] [" MsgDone" ]
1706+ ]
1707+
1708+
14311709--------------------------------------------------------------------------------
14321710-- ForgeEvent Tracer
14331711--------------------------------------------------------------------------------
0 commit comments