Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cardano-node/src/Cardano/Node/TraceConstraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, HasTxId
import Ouroboros.Consensus.Node.NetworkProtocolVersion
(HasNetworkProtocolVersion (BlockNodeToClientVersion, BlockNodeToNodeVersion))
import Ouroboros.Consensus.Node.Run (RunNode, SerialiseNodeToNodeConstraints)
import Ouroboros.Consensus.Peras.SelectView
import Ouroboros.Consensus.Protocol.Abstract (SelectView, ValidationErr)
import Ouroboros.Consensus.Shelley.Ledger.Mempool (GenTx, TxId)
import Ouroboros.Network.Block (Serialised)
Expand Down Expand Up @@ -51,7 +52,7 @@ type TraceConstraints blk =
, ToObject (LedgerError blk)
, ToObject (LedgerEvent blk)
, ToObject (OtherHeaderEnvelopeError blk)
, ToObject (SelectView (BlockProtocol blk))
, ToObject (WeightedSelectView (BlockProtocol blk))
, ToObject (ValidationErr (BlockProtocol blk))
, ToObject (CannotForge blk)
, ToObject (ForgeStateUpdateError blk)
Expand All @@ -66,7 +67,7 @@ type TraceConstraints blk =
, LogFormatting (LedgerUpdate blk)
, LogFormatting (LedgerWarning blk)
, LogFormatting (OtherHeaderEnvelopeError blk)
, LogFormatting (SelectView (BlockProtocol blk))
, LogFormatting (WeightedSelectView (BlockProtocol blk))
, LogFormatting (ValidationErr (BlockProtocol blk))
, LogFormatting (CannotForge blk)
, LogFormatting (ForgeStateUpdateError blk)
Expand Down
21 changes: 21 additions & 0 deletions cardano-node/src/Cardano/Node/Tracing/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import qualified Network.Mux as Mux
import qualified Network.Socket as Socket
import qualified Options.Applicative as Opt
import System.IO
import qualified Ouroboros.Consensus.MiniProtocol.ObjectDiffusion.PerasCert as Consensus


data TraceDocumentationCmd
Expand Down Expand Up @@ -371,6 +372,24 @@ docTracersFirstPhase condConfigFileName = do
mempoolTrDoc <- documentTracer (mempoolTr ::
Logging.Trace IO (TraceEventMempool blk))

perasCertDiffusionInboundTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Peras", "CertDiffusion", "Inbound"]
configureTracers configReflection trConfig [perasCertDiffusionInboundTr]
perasCertDiffusionInboundTrDoc <- documentTracer (perasCertDiffusionInboundTr ::
Logging.Trace IO (BlockFetch.TraceLabelPeer
remotePeer
(Consensus.TracePerasCertDiffusionInbound blk)))

perasCertDiffusionOutboundTracer <- mkCardanoTracer
trBase trForward mbTrEKG
["Peras", "CertDiffusion", "Outbound"]
configureTracers configReflection trConfig [perasCertDiffusionOutboundTracer]
perasCertDiffusionOutboundTrDoc <- documentTracer (perasCertDiffusionOutboundTracer ::
Logging.Trace IO (BlockFetch.TraceLabelPeer
remotePeer
(Consensus.TracePerasCertDiffusionOutbound blk)))

forgeTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Forge", "Loop"]
Expand Down Expand Up @@ -778,6 +797,8 @@ docTracersFirstPhase condConfigFileName = do
<> txOutboundTrDoc
<> localTxSubmissionServerTrDoc
<> mempoolTrDoc
<> perasCertDiffusionInboundTrDoc
<> perasCertDiffusionOutboundTrDoc
<> forgeTrDoc
<> forgeStatsTrDoc
<> blockchainTimeTrDoc
Expand Down
7 changes: 3 additions & 4 deletions cardano-node/src/Cardano/Node/Tracing/Era/Byron.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Ouroboros.Consensus.Byron.Ledger (ByronBlock (..),
import Ouroboros.Consensus.Byron.Ledger.Inspect (ByronLedgerUpdate (..),
ProtocolUpdate (..), UpdateState (..))
import Ouroboros.Consensus.Ledger.SupportsMempool (GenTx, txId)
import Ouroboros.Consensus.Protocol.PBFT (PBftSelectView (..))
import Ouroboros.Consensus.Protocol.PBFT (PBft, PBftTiebreakerView (..))
import Ouroboros.Consensus.Util.Condense (condense)
import Ouroboros.Network.Block (blockHash, blockNo, blockSlot)

Expand Down Expand Up @@ -213,10 +213,9 @@ instance LogFormatting ByronOtherHeaderEnvelopeError where
, "slot" .= slot
]

instance LogFormatting PBftSelectView where
forMachine _dtal (PBftSelectView blkNo isEBB) =
instance LogFormatting PBftTiebreakerView where
forMachine _dtal (PBftTiebreakerView isEBB) =
mconcat
[ "kind" .= String "PBftSelectView"
, "blockNo" .= blkNo
, "isEBB" .= fromIsEBB isEBB
]
32 changes: 18 additions & 14 deletions cardano-node/src/Cardano/Node/Tracing/Era/HardFork.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import Cardano.Logging
import Cardano.Slotting.Slot (EpochSize (..))
import Cardano.Tracing.OrphanInstances.HardFork ()
import Ouroboros.Consensus.Block (BlockProtocol, CannotForge, ForgeStateInfo,
ForgeStateUpdateError)
ForgeStateUpdateError, PerasWeight (..))
import Ouroboros.Consensus.BlockchainTime (getSlotLength)
import Ouroboros.Consensus.Cardano.Condense ()
import Ouroboros.Consensus.HardFork.Combinator
import Ouroboros.Consensus.HardFork.Combinator.AcrossEras (EraMismatch (..),
OneEraCannotForge (..), OneEraEnvelopeErr (..), OneEraForgeStateInfo (..),
OneEraForgeStateUpdateError (..), OneEraLedgerError (..),
OneEraLedgerUpdate (..), OneEraLedgerWarning (..), OneEraSelectView (..),
OneEraLedgerUpdate (..), OneEraLedgerWarning (..), OneEraTiebreakerView (..),
OneEraValidationErr (..), mkEraMismatch)
import Ouroboros.Consensus.HardFork.Combinator.Condense ()
import Ouroboros.Consensus.HardFork.History
Expand All @@ -36,7 +36,8 @@ import Ouroboros.Consensus.HeaderValidation (OtherHeaderEnvelopeError)
import Ouroboros.Consensus.Ledger.Abstract (LedgerError)
import Ouroboros.Consensus.Ledger.Inspect (LedgerUpdate, LedgerWarning)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr)
import Ouroboros.Consensus.Protocol.Abstract (SelectView, ValidationErr)
import Ouroboros.Consensus.Peras.SelectView
import Ouroboros.Consensus.Protocol.Abstract (TiebreakerView (..), ValidationErr)
import Ouroboros.Consensus.TypeFamilyWrappers
import Ouroboros.Consensus.Util.Condense (Condense (..))

Expand Down Expand Up @@ -349,19 +350,22 @@ instance LogFormatting (ForgeStateUpdateError blk) => LogFormatting (WrapForgeSt
-- instances for HardForkSelectView
--

instance All (LogFormatting `Compose` WrapSelectView) xs => LogFormatting (HardForkSelectView xs) where
-- elide BlockNo as it is already contained in every per-era SelectView
-- TODO: use level DMinimal for a textual representation without the block number,
-- like this: `forMachine DMinimal . getHardForkSelectView`, and update the different SelectView instances
-- to not print the blockNr
forMachine dtal = forMachine dtal . dropBlockNo . getHardForkSelectView
instance All (LogFormatting `Compose` WrapTiebreakerView) xs => LogFormatting (HardForkTiebreakerView xs) where
forMachine dtal = forMachine dtal . getHardForkTiebreakerView

instance All (LogFormatting `Compose` WrapSelectView) xs => LogFormatting (OneEraSelectView xs) where
instance LogFormatting (TiebreakerView protocol) => LogFormatting (WeightedSelectView protocol) where
forMachine dtal sv = mconcat
[ "length" .= wsvLength sv
, "weightBoost" .= unPerasWeight (wsvWeightBoost sv)
, forMachine dtal (wsvTiebreaker sv)
]

instance All (LogFormatting `Compose` WrapTiebreakerView) xs => LogFormatting (OneEraTiebreakerView xs) where
forMachine dtal =
hcollapse
. hcmap (Proxy @(LogFormatting `Compose` WrapSelectView))
. hcmap (Proxy @(LogFormatting `Compose` WrapTiebreakerView))
(K . forMachine dtal)
. getOneEraSelectView
. getOneEraTiebreakerView

instance LogFormatting (SelectView (BlockProtocol blk)) => LogFormatting (WrapSelectView blk) where
forMachine dtal = forMachine dtal . unwrapSelectView
instance LogFormatting (TiebreakerView (BlockProtocol blk)) => LogFormatting (WrapTiebreakerView blk) where
forMachine dtal = forMachine dtal . unwrapTiebreakerView
26 changes: 12 additions & 14 deletions cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import Cardano.Tracing.OrphanInstances.Shelley ()
import Ouroboros.Consensus.Ledger.SupportsMempool (txId)
import qualified Ouroboros.Consensus.Ledger.SupportsMempool as SupportsMempool
import qualified Ouroboros.Consensus.Protocol.Praos as Praos
import Ouroboros.Consensus.Protocol.Praos.Common (PraosChainSelectView (..))
import Ouroboros.Consensus.Protocol.Praos.Common (PraosTiebreakerView (..))
import Ouroboros.Consensus.Protocol.TPraos (TPraosCannotForge (..))
import Ouroboros.Consensus.Shelley.Ledger hiding (TxId)
import qualified Ouroboros.Consensus.Shelley.Ledger as Consensus
Expand Down Expand Up @@ -1292,20 +1292,18 @@ instance LogFormatting Praos.PraosEnvelopeError where
, "blockSize" .= blockSize
]

instance Ledger.Crypto c => LogFormatting (PraosChainSelectView c) where
forMachine _ PraosChainSelectView {
csvChainLength
, csvSlotNo
, csvIssuer
, csvIssueNo
, csvTieBreakVRF
instance Ledger.Crypto c => LogFormatting (PraosTiebreakerView c) where
forMachine _ PraosTiebreakerView {
ptvSlotNo
, ptvIssuer
, ptvIssueNo
, ptvTieBreakVRF
} =
mconcat [ "kind" .= String "PraosChainSelectView"
, "chainLength" .= csvChainLength
, "slotNo" .= csvSlotNo
, "issuerHash" .= hashKey csvIssuer
, "issueNo" .= csvIssueNo
, "tieBreakVRF" .= renderVRF csvTieBreakVRF
mconcat [ "kind" .= String "PraosTiebreakerView"
, "slotNo" .= ptvSlotNo
, "issuerHash" .= hashKey ptvIssuer
, "issueNo" .= ptvIssueNo
, "tieBreakVRF" .= renderVRF ptvTieBreakVRF
]
where
renderVRF = Text.decodeUtf8 . B16.encode . Crypto.getOutputVRFBytes
Expand Down
19 changes: 19 additions & 0 deletions cardano-node/src/Cardano/Node/Tracing/Tracers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf
["Mempool"]
configureTracers configReflection trConfig [mempoolTr]

!perasCertDiffusionInboundTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Peras", "CertDiffusion", "Inbound"]
configureTracers configReflection trConfig [perasCertDiffusionInboundTr]

!perasCertDiffusionOutboundTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Peras", "CertDiffusion", "Outbound"]
configureTracers configReflection trConfig [perasCertDiffusionOutboundTr]

!forgeTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Forge", "Loop"]
Expand Down Expand Up @@ -408,6 +418,8 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf
traceWith consensusCsjTr
, Consensus.dbfTracer = Tracer $
traceWith consensusDbfTr
, Consensus.perasCertDiffusionInboundTracer = Tracer $ traceWith perasCertDiffusionInboundTr
, Consensus.perasCertDiffusionOutboundTracer = Tracer $ traceWith perasCertDiffusionOutboundTr
}

mkNodeToClientTracers :: forall blk.
Expand Down Expand Up @@ -492,6 +504,11 @@ mkNodeToNodeTracers configReflection trBase trForward mbTrEKG _trDataPoint trCon
["TxSubmission", "Remote"]
configureTracers configReflection trConfig [txSubmission2Tracer]

!perasCertDiffusionTracer <- mkCardanoTracer
trBase trForward mbTrEKG
["Peras", "CertDiffusion", "Remote"]
configureTracers configReflection trConfig [perasCertDiffusionTracer]

!keepAliveTracer <- mkCardanoTracer
trBase trForward mbTrEKG
["KeepAlive", "Remote"]
Expand All @@ -517,6 +534,8 @@ mkNodeToNodeTracers configReflection trBase trForward mbTrEKG _trDataPoint trCon
traceWith keepAliveTracer
, NtN.tPeerSharingTracer = Tracer $
traceWith peerSharingTracer
, NtN.tPerasCertDiffusionTracer = Tracer $
traceWith perasCertDiffusionTracer
}

mkDiffusionTracers
Expand Down
Loading
Loading