Skip to content

Commit

Permalink
TODO: add LoE Consensus tracers
Browse files Browse the repository at this point in the history
  • Loading branch information
dnadales committed Mar 28, 2024
1 parent 7c60413 commit b18169c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Ouroboros.Consensus.Cardano
import qualified Ouroboros.Consensus.Cardano as Consensus
import qualified Ouroboros.Consensus.Cardano.CanHardFork as Consensus
import Ouroboros.Consensus.Cardano.Condense ()
import Ouroboros.Consensus.Config (emptyCheckpointsMap)
import Ouroboros.Consensus.HardFork.Combinator.Condense ()
import qualified Ouroboros.Consensus.Mempool.Capacity as TxLimits
import qualified Ouroboros.Consensus.Shelley.Node.Praos as Praos
Expand Down Expand Up @@ -305,6 +306,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
(maybe 9 fromIntegral npcTestConwayHardForkAtVersion)
Just epochNo -> Consensus.TriggerHardForkAtEpoch epochNo
}
, checkpoints = emptyCheckpointsMap
}

----------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ instance ( LogFormatting (Header blk)
forHuman (ChainDB.ChainSelectionForFutureBlock pt) =
"Chain selection run for block previously from future: " <> renderRealPointAsPhrase pt
forHuman (ChainDB.PipeliningEvent ev') = forHumanOrMachine ev'
forHuman (ChainDB.AddedReprocessLoEBlocksToQueue) = "FIXME"

Check warning on line 421 in cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Node.Tracing.Tracers.ChainDB: Redundant bracket ▫︎ Found: "(ChainDB.AddedReprocessLoEBlocksToQueue)" ▫︎ Perhaps: "ChainDB.AddedReprocessLoEBlocksToQueue"
forHuman (ChainDB.PoppedReprocessLoEBlocksFromQueue) = "FIXME"

Check warning on line 422 in cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Node.Tracing.Tracers.ChainDB: Redundant bracket ▫︎ Found: "(ChainDB.PoppedReprocessLoEBlocksFromQueue)" ▫︎ Perhaps: "ChainDB.PoppedReprocessLoEBlocksFromQueue"
forHuman (ChainDB.ChainSelectionLoEDebug _ _) = "FIXME"
forMachine dtal (ChainDB.IgnoreBlockOlderThanK pt) =
mconcat [ "kind" .= String "IgnoreBlockOlderThanK"
, "block" .= forMachine dtal pt ]
Expand Down Expand Up @@ -493,6 +496,9 @@ instance ( LogFormatting (Header blk)
, "block" .= forMachine dtal pt ]
forMachine dtal (ChainDB.PipeliningEvent ev') =
forMachine dtal ev'
forMachine _dtal (ChainDB.AddedReprocessLoEBlocksToQueue) = mconcat [ "kind" .= String "FIXME" ]

Check warning on line 499 in cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Node.Tracing.Tracers.ChainDB: Redundant bracket ▫︎ Found: "(ChainDB.AddedReprocessLoEBlocksToQueue)" ▫︎ Perhaps: "ChainDB.AddedReprocessLoEBlocksToQueue"
forMachine _dtal (ChainDB.PoppedReprocessLoEBlocksFromQueue) = mconcat [ "kind" .= String "FIXME" ]

Check warning on line 500 in cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Node.Tracing.Tracers.ChainDB: Redundant bracket ▫︎ Found: "(ChainDB.PoppedReprocessLoEBlocksFromQueue)" ▫︎ Perhaps: "ChainDB.PoppedReprocessLoEBlocksFromQueue"
forMachine _dtal (ChainDB.ChainSelectionLoEDebug _ _) = mconcat [ "kind" .= String "FIXME" ]

asMetrics (ChainDB.SwitchedToAFork _warnings selChangedInfo _oldChain newChain) =
let ChainInformation { slots, blocks, density, epoch, slotInEpoch } =
Expand Down Expand Up @@ -548,6 +554,12 @@ instance MetaTrace (ChainDB.TraceAddBlockEvent blk) where
Namespace [] ["ChainSelectionForFutureBlock"]
namespaceFor (ChainDB.PipeliningEvent ev') =
nsPrependInner "PipeliningEvent" (namespaceFor ev')
namespaceFor (ChainDB.AddedReprocessLoEBlocksToQueue) =

Check warning on line 557 in cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Node.Tracing.Tracers.ChainDB: Redundant bracket ▫︎ Found: "(ChainDB.AddedReprocessLoEBlocksToQueue)" ▫︎ Perhaps: "ChainDB.AddedReprocessLoEBlocksToQueue"
Namespace [] ["AddedReprocessLoEBlocksToQueue"]
namespaceFor (ChainDB.PoppedReprocessLoEBlocksFromQueue) =

Check warning on line 559 in cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Node.Tracing.Tracers.ChainDB: Redundant bracket ▫︎ Found: "(ChainDB.PoppedReprocessLoEBlocksFromQueue)" ▫︎ Perhaps: "ChainDB.PoppedReprocessLoEBlocksFromQueue"
Namespace [] ["PoppedReprocessLoEBlocksFromQueue"]
namespaceFor (ChainDB.ChainSelectionLoEDebug _ _) =
Namespace [] ["FIXME: ChainSelectionLoEDebug ?? ??"]

severityFor (Namespace _ ["IgnoreBlockOlderThanK"]) _ = Just Info
severityFor (Namespace _ ["IgnoreBlockAlreadyInVolatileDB"]) _ = Just Info
Expand Down
44 changes: 44 additions & 0 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ instance HasSeverityAnnotation (ChainDB.TraceEvent blk) where
ChainDB.UpdateLedgerDbTraceEvent {} -> Debug
ChainDB.ChainSelectionForFutureBlock{} -> Debug
ChainDB.PipeliningEvent {} -> Debug
ChainDB.AddedReprocessLoEBlocksToQueue -> Info
ChainDB.PoppedReprocessLoEBlocksFromQueue -> Info
ChainDB.ChainSelectionLoEDebug _ _ -> Debug


getSeverityAnnotation (ChainDB.TraceLedgerReplayEvent ev) = case ev of
LedgerDB.ReplayFromGenesis {} -> Info
Expand Down Expand Up @@ -236,6 +240,10 @@ instance HasSeverityAnnotation (TraceChainSyncClientEvent blk) where
getSeverityAnnotation (TraceRolledBack _) = Notice
getSeverityAnnotation (TraceException _) = Warning
getSeverityAnnotation (TraceTermination _) = Notice
getSeverityAnnotation (TraceValidatedHeader _) = Info
getSeverityAnnotation (TraceWaitingBeyondForecastHorizon _) = Info
getSeverityAnnotation (TraceAccessingForecastHorizon _) = Info
getSeverityAnnotation (TraceGaveLoPToken _ _ _) = Info


instance HasPrivacyAnnotation (TraceChainSyncServerEvent blk)
Expand Down Expand Up @@ -487,6 +495,12 @@ instance ( ConvertRawHash blk
"About to add block to queue: " <> renderRealPointAsPhrase pt
FallingEdgeWith sz ->
"Block added to queue: " <> renderRealPointAsPhrase pt <> " queue size " <> condenseT sz
ChainDB.AddedReprocessLoEBlocksToQueue ->
"Added LoE blocks to queue."
ChainDB.PoppedReprocessLoEBlocksFromQueue ->
"Added LoE blocks to queue."
ChainDB.ChainSelectionLoEDebug _anchFrag0 _anchFrag1 -> "FIXME"

ChainDB.PoppedBlockFromQueue edgePt ->
case edgePt of
RisingEdge ->
Expand Down Expand Up @@ -980,6 +994,14 @@ instance ( ConvertRawHash blk
mconcat [ "kind" .= String "TraceAddBlockEvent.PipeliningEvent.OutdatedTentativeHeader"
, "block" .= renderPointForVerbosity verb (blockPoint hdr)
]
ChainDB.AddedReprocessLoEBlocksToQueue ->
mconcat [ "kind" .= String "AddedReprocessLoEBlocksToQueue" ]
ChainDB.PoppedReprocessLoEBlocksFromQueue ->
mconcat [ "kind" .= String "PoppedReprocessLoEBlocksFromQueue" ]
ChainDB.ChainSelectionLoEDebug _frag0 _frag1 ->
mconcat [ "kind" .= String "ChainSelectionLoEDebug"
--, "???" .= undefined
]

where
addedHdrsNewChain
Expand Down Expand Up @@ -1303,6 +1325,20 @@ instance (ConvertRawHash blk, LedgerSupportsProtocol blk)
TraceTermination reason ->
mconcat [ "kind" .= String "ChainSyncClientEvent.TraceTermination"
, "reason" .= String (pack $ show reason) ]
TraceValidatedHeader h ->
mconcat [ "kind" .= String "ChainSyncClientEvent.TraceValidatedHeader"
, tipToObject (tipFromHeader h) ]
TraceWaitingBeyondForecastHorizon slotNo ->
mconcat [ "kind" .= String "ChainSyncClientEvent.TraceWaitingBeyondForecastHorizon"
, "slotNo" .= condense slotNo ]
TraceAccessingForecastHorizon slotNo ->
mconcat [ "kind" .= String "ChainSyncClientEvent.TraceAccessingForecastHorizon"
, "slotNo" .= condense slotNo ]
TraceGaveLoPToken tokenGiven h bestBlockNumberPriorToH ->
mconcat [ "kind" .= String "ChainSyncClientEvent.TraceGaveLoPToken"
, "given" .= String (pack $ show tokenGiven)
, tipToObject (tipFromHeader h)
, "blockNo" .= bestBlockNumberPriorToH ]

instance ConvertRawHash blk
=> ToObject (TraceChainSyncServerEvent blk) where
Expand Down Expand Up @@ -1537,6 +1573,14 @@ instance ToObject selection => ToObject (TraceGsmEvent selection) where
, "currentSelection" .= toObject verb s
, "age" .= toJSON (show a)
]
toObject _verb (GsmEventPreSyncingToSyncing) =

Check warning on line 1576 in cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Tracing.OrphanInstances.Consensus: Redundant bracket ▫︎ Found: "(GsmEventPreSyncingToSyncing)" ▫︎ Perhaps: "GsmEventPreSyncingToSyncing"
mconcat
[ "kind" .= String ""
]
toObject _verb (GsmEventSyncingToPreSyncing) =

Check warning on line 1580 in cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Tracing.OrphanInstances.Consensus: Redundant bracket ▫︎ Found: "(GsmEventSyncingToPreSyncing)" ▫︎ Perhaps: "GsmEventSyncingToPreSyncing"
mconcat
[ "kind" .= String "GsmEventSyncingToPreSyncing"
]

instance ConvertRawHash blk => ToObject (Tip blk) where
toObject _verb TipGenesis =
Expand Down

0 comments on commit b18169c

Please sign in to comment.