Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TraceForgeEvent logging details #537

Merged
merged 1 commit into from
Feb 5, 2020
Merged
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: 4 additions & 1 deletion cardano-config/src/Cardano/Config/Protocol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import Ouroboros.Consensus.Block (Header)
import Ouroboros.Consensus.BlockchainTime
(SlotLength, slotLengthFromSec,
SlotLengths, singletonSlotLengths)
import Ouroboros.Consensus.Mempool.API (ApplyTxErr, GenTx, GenTxId)
import Ouroboros.Consensus.Mempool.API (ApplyTxErr, GenTx, GenTxId,
HasTxId, TxId)
import Ouroboros.Consensus.Node.ProtocolInfo (NumCoreNodes (..),
PBftLeaderCredentials,
PBftLeaderCredentialsError,
Expand Down Expand Up @@ -73,11 +74,13 @@ type TraceConstraints blk =
, Condense (Header blk)
, Condense (HeaderHash blk)
, Condense (GenTx blk)
, HasTxId (GenTx blk)
, Show (ApplyTxErr blk)
, Show (GenTx blk)
, Show (GenTxId blk)
, Show blk
, Show (Header blk)
, Show (TxId (GenTx blk))
)

{-------------------------------------------------------------------------------
Expand Down
28 changes: 19 additions & 9 deletions cardano-node/src/Cardano/Tracing/ToObjectOrphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import Ouroboros.Consensus.ChainSyncClient
import Ouroboros.Consensus.ChainSyncServer
(TraceChainSyncServerEvent(..))
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Mempool.API (GenTx, GenTxId)
import Ouroboros.Consensus.Mempool.API (GenTx, GenTxId, HasTxId, TxId, txId)
import Ouroboros.Consensus.Node.Tracers (TraceForgeEvent (..))
import Ouroboros.Consensus.TxSubmission
(TraceLocalTxSubmissionServerEvent (..))
Expand Down Expand Up @@ -319,12 +319,12 @@ instance DefineSeverity (TraceForgeEvent blk tx) where
defineSeverity TraceStartLeadershipCheck {} = Info
defineSeverity TraceNodeNotLeader {} = Info
defineSeverity TraceNodeIsLeader {} = Info
defineSeverity TraceNoLedgerState {} = Warning
defineSeverity TraceNoLedgerView {} = Warning
defineSeverity TraceBlockFromFuture {} = Warning
defineSeverity TraceNoLedgerState {} = Error
defineSeverity TraceNoLedgerView {} = Error
defineSeverity TraceBlockFromFuture {} = Error
defineSeverity TraceAdoptedBlock {} = Info
defineSeverity TraceDidntAdoptBlock {} = Warning
defineSeverity TraceForgedInvalidBlock {} = Alert
defineSeverity TraceDidntAdoptBlock {} = Error
defineSeverity TraceForgedInvalidBlock {} = Error

-- | instances of @Transformable@

Expand Down Expand Up @@ -362,7 +362,8 @@ instance Transformable Text IO (TraceTxSubmissionOutbound
instance Transformable Text IO (TraceLocalTxSubmissionServerEvent blk) where
trTransformer _ verb tr = trStructured verb tr

instance (Show blk, Show tx, ProtocolLedgerView blk) => Transformable Text IO (TraceForgeEvent blk tx) where
instance (Condense (HeaderHash blk), Show (TxId tx), HasTxId tx, Show blk, Show tx, ProtocolLedgerView blk)
=> Transformable Text IO (TraceForgeEvent blk tx) where
trTransformer StructuredLogging verb tr = trStructured verb tr
trTransformer TextualRepresentation _verb tr = Tracer $ \s ->
traceWith tr =<< LogObject <$> pure mempty
Expand Down Expand Up @@ -842,11 +843,20 @@ instance ToObject (TraceLocalTxSubmissionServerEvent blk) where
toObject _verb _ =
mkObject [ "kind" .= String "TraceLocalTxSubmissionServerEvent" ]

instance ProtocolLedgerView blk => ToObject (TraceForgeEvent blk tx) where
toObject _verb (TraceAdoptedBlock slotNo _blk _txs) =
instance (HasTxId tx, ProtocolLedgerView blk, Condense (HeaderHash blk), Show (TxId tx))
=> ToObject (TraceForgeEvent blk tx) where
toObject MaximalVerbosity (TraceAdoptedBlock slotNo blk txs) =
mkObject
[ "kind" .= String "TraceAdoptedBlock"
, "slot" .= toJSON (unSlotNo slotNo)
, "block hash" .= (condense $ blockHash blk)
, "tx ids" .= (show $ map txId txs)
]
toObject _verb (TraceAdoptedBlock slotNo blk _txs) =
mkObject
[ "kind" .= String "TraceAdoptedBlock"
, "slot" .= toJSON (unSlotNo slotNo)
, "block hash" .= (condense $ blockHash blk)
]
toObject _verb (TraceBlockFromFuture currentSlot tip) =
mkObject
Expand Down