Skip to content

Commit ebdaac5

Browse files
iohk-bors[bot]jutarodeepfirehamishmack
authored
Merge #4581
4581: Fix missing trace-forward messages r=deepfire a=jutaro Fix the bug and add a test case. Co-authored-by: Yupanqui <[email protected]> Co-authored-by: Kosyrev Serge <[email protected]> Co-authored-by: Hamish Mackenzie <[email protected]>
2 parents ffcf2c0 + b6553af commit ebdaac5

File tree

48 files changed

+1200
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1200
-263
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ logs
6363
/example
6464
/.hlint.yaml
6565
/testnet
66+
67+
.vscode/

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ps: ## Plain-text list of profiles
6868
##
6969
## Profile-based cluster shells (autogenerated targets)
7070
##
71-
PROFILES_BASE := default plutus oldtracing
71+
PROFILES_BASE := default plutus oldtracing idle tracer-only
7272
PROFILES_STARTSTOP := startstop startstop-p2p startstop-plutus startstop-notracer startstop-oldtracing
7373
PROFILES_CI_TEST := ci-test ci-test-p2p ci-test-plutus ci-test-notracer ci-test-dense10
7474
PROFILES_CI_BENCH := ci-bench ci-bench-p2p ci-bench-plutus ci-bench-notracer

bench/tx-generator/tx-generator.cabal

+9-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ cabal-version: >= 1.10
1212
extra-source-files: README.md
1313
data-files: data/protocol-parameters.json
1414

15+
common project-config
16+
if os(windows)
17+
buildable: False
18+
1519
library
1620
hs-source-dirs: src
1721
ghc-options: -Wall
@@ -26,23 +30,23 @@ library
2630

2731
exposed-modules:
2832
Cardano.Benchmarking.Command
29-
Cardano.Benchmarking.Compiler
33+
Cardano.Benchmarking.Compiler
3034
Cardano.Benchmarking.GeneratorTx
3135
Cardano.Benchmarking.GeneratorTx.Genesis
3236
Cardano.Benchmarking.GeneratorTx.NodeToNode
3337
Cardano.Benchmarking.GeneratorTx.SizedMetadata
3438
Cardano.Benchmarking.GeneratorTx.Submission
3539
Cardano.Benchmarking.GeneratorTx.SubmissionClient
36-
Cardano.Benchmarking.LogTypes
40+
Cardano.Benchmarking.LogTypes
3741
Cardano.Benchmarking.NixOptions
3842
Cardano.Benchmarking.OuroborosImports
3943
Cardano.Benchmarking.Script
4044
Cardano.Benchmarking.Script.Action
4145
Cardano.Benchmarking.Script.Aeson
4246
Cardano.Benchmarking.Script.Core
4347
Cardano.Benchmarking.Script.Env
44-
Cardano.Benchmarking.Script.NodeConfig
45-
Cardano.Benchmarking.Script.Selftest
48+
Cardano.Benchmarking.Script.NodeConfig
49+
Cardano.Benchmarking.Script.Selftest
4650
Cardano.Benchmarking.Script.Setters
4751
Cardano.Benchmarking.Script.Store
4852
Cardano.Benchmarking.Script.Types
@@ -52,7 +56,7 @@ library
5256
Cardano.Benchmarking.Version
5357
Cardano.Benchmarking.Wallet
5458
Cardano.Benchmarking.PlutusExample
55-
59+
5660
Cardano.TxGenerator.Fund
5761
Cardano.TxGenerator.FundQueue
5862
Cardano.TxGenerator.PureExample

cardano-node-chairman/cardano-node-chairman.cabal

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ build-type: Simple
1212

1313
common base { build-depends: base >= 4.14 && < 4.15 }
1414

15+
if os(windows)
16+
buildable: False
17+
18+
1519
common project-config
1620
default-language: Haskell2010
1721
default-extensions: NoImplicitPrelude

cardano-node/src/Cardano/Node/Tracing/Documentation.hs

+8-11
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import Cardano.Node.Tracing.Tracers.BlockReplayProgress
3535
import Cardano.Node.Tracing.Tracers.ChainDB
3636
import Cardano.Node.Tracing.Tracers.Consensus
3737
import Cardano.Node.Tracing.Tracers.Diffusion
38-
import Cardano.Node.Tracing.Tracers.ForgingThreadStats (docForgeStats, forgeThreadStats)
38+
import Cardano.Node.Tracing.Tracers.ForgingThreadStats (
39+
docForgeStats, forgeThreadStats)
3940
import Cardano.Node.Tracing.Tracers.KESInfo
4041
import Cardano.Node.Tracing.Tracers.NodeToClient
4142
import Cardano.Node.Tracing.Tracers.NodeToNode
@@ -49,7 +50,6 @@ import Cardano.Node.Handlers.Shutdown (ShutdownTrace)
4950
import Cardano.Node.Startup
5051
import Cardano.Node.TraceConstraints
5152

52-
5353
import Ouroboros.Consensus.Block.Forging
5454
import Ouroboros.Consensus.BlockchainTime.WallClock.Types (RelativeTime)
5555
import Ouroboros.Consensus.BlockchainTime.WallClock.Util (TraceBlockchainTimeEvent (..))
@@ -424,22 +424,19 @@ docTracers configFileName outputFileName _ _ _ = do
424424
mkCardanoTracer'
425425
trBase trForward mbTrEKG
426426
["Forge", "Stats"]
427-
namesForForge
428-
severityForge
427+
namesForForge2
428+
severityForge2
429429
allPublic
430430
forgeThreadStats
431431

432432
configureTracers trConfig docForge [forgeTr, forgeThreadStatsTr]
433433
forgeTrDoc <- documentTracer trConfig forgeTr
434-
(docForge :: Documented
435-
(Either (Consensus.TraceForgeEvent blk)
436-
TraceStartLeadershipCheckPlus))
434+
(docForge :: Documented (Either (Consensus.TraceForgeEvent blk)
435+
TraceStartLeadershipCheckPlus))
437436

438437
forgeThreadStatsTrDoc <- documentTracer trConfig forgeThreadStatsTr
439-
(docForgeStats :: Documented
440-
(Either
441-
(Consensus.TraceForgeEvent blk)
442-
TraceStartLeadershipCheckPlus))
438+
(docForgeStats :: Documented (Either (Consensus.TraceForgeEvent blk)
439+
TraceStartLeadershipCheckPlus))
443440

444441
blockchainTimeTr <- mkCardanoTracer
445442
trBase trForward mbTrEKG

cardano-node/src/Cardano/Node/Tracing/Tracers.hs

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Cardano.Node.Tracing.Tracers.BlockReplayProgress
2323
import Cardano.Node.Tracing.Tracers.ChainDB
2424
import Cardano.Node.Tracing.Tracers.Consensus
2525
import Cardano.Node.Tracing.Tracers.Diffusion
26-
import Cardano.Node.Tracing.Tracers.ForgingThreadStats (forgeThreadStats)
26+
import Cardano.Node.Tracing.Tracers.ForgingThreadStats (docForgeStats, forgeThreadStats)
2727
import Cardano.Node.Tracing.Tracers.KESInfo
2828
import Cardano.Node.Tracing.Tracers.NodeToClient
2929
import Cardano.Node.Tracing.Tracers.NodeToNode
@@ -352,11 +352,12 @@ mkConsensusTracers trBase trForward mbTrEKG _trDataPoint trConfig nodeKernel = d
352352
forgeThreadStatsTr <- mkCardanoTracer'
353353
trBase trForward mbTrEKG
354354
["Forge", "Stats"]
355-
namesForForge
356-
severityForge
355+
namesForForge2
356+
severityForge2
357357
allPublic
358358
forgeThreadStats
359-
configureTracers trConfig docForge [forgeTr, forgeThreadStatsTr]
359+
configureTracers trConfig docForge [forgeTr]
360+
configureTracers trConfig docForgeStats [forgeThreadStatsTr]
360361
blockchainTimeTr <- mkCardanoTracer
361362
trBase trForward mbTrEKG
362363
["BlockchainTime"]

cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs

+18-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ module Cardano.Node.Tracing.Tracers.Consensus
6060
, namesForForge
6161
, docForge
6262

63+
, severityForge2
64+
, namesForForge2
65+
, docForge2
66+
6367
, namesForBlockchainTime
6468
, severityBlockchainTime
6569
, docBlockchainTime
@@ -90,6 +94,7 @@ import Cardano.Node.Tracing.Era.Shelley ()
9094
import Cardano.Node.Tracing.Formatting ()
9195
import Cardano.Node.Tracing.Render
9296
import Cardano.Node.Tracing.Tracers.StartLeadershipCheck
97+
import Cardano.Node.Tracing.Tracers.ForgingThreadStats(ForgingStats)
9398
import Cardano.Prelude hiding (All, Show, show)
9499

95100
import Cardano.Protocol.TPraos.OCert (KESPeriod (..))
@@ -1095,7 +1100,14 @@ namesForForge'' TraceForgedInvalidBlock {} = ["ForgedInvalidBlock"]
10951100
namesForForge'' TraceAdoptedBlock {} = ["AdoptedBlock"]
10961101

10971102
namesForForge'''' :: TraceStartLeadershipCheckPlus -> [Text]
1098-
namesForForge'''' TraceStartLeadershipCheckPlus{} = ["StartLeadershipCheckPlus"]
1103+
namesForForge'''' TraceStartLeadershipCheckPlus{} = ["StartLeadershipCheck"]
1104+
1105+
namesForForge2 :: ForgingStats -> [Text]
1106+
namesForForge2 _ = ["StartLeadershipCheck"]
1107+
1108+
severityForge2 :: ForgingStats -> SeverityS
1109+
severityForge2 _ = Info
1110+
10991111

11001112
instance ( tx ~ GenTx blk
11011113
, ConvertRawHash blk
@@ -1544,7 +1556,7 @@ docForge' = Documented [
15441556
"We adopted the block we produced, we also trace the transactions\
15451557
\ that were adopted."
15461558
, DocMsg
1547-
["StartLeadershipCheckPlus"]
1559+
["StartLeadershipCheck"]
15481560
[ ("Forge.AboutToLeadSlotLast", "")
15491561
, ("Forge.UtxoSize", "")
15501562
, ("Forge.DelegMapSize", "")
@@ -1554,6 +1566,10 @@ docForge' = Documented [
15541566

15551567
]
15561568

1569+
docForge2 :: Documented ForgingStats
1570+
docForge2 = addDocumentedNamespace [] docForge'
1571+
1572+
15571573
instance ( tx ~ GenTx blk
15581574
, ConvertRawHash blk
15591575
, GetHeader blk

cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs

+14-12
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ instance LogFormatting ForgeThreadStats where
6969
emptyForgeThreadStats :: ForgeThreadStats
7070
emptyForgeThreadStats = ForgeThreadStats 0 0 0 0 0
7171

72-
docForgeStats :: Documented
73-
(Either
74-
(Consensus.TraceForgeEvent blk)
75-
TraceStartLeadershipCheckPlus)
72+
docForgeStats :: Documented (Either (Consensus.TraceForgeEvent blk)
73+
TraceStartLeadershipCheckPlus)
7674
docForgeStats = Documented [
7775
DocMsg
7876
[]
@@ -85,7 +83,7 @@ docForgeStats = Documented [
8583
,("Forge.SlotsMissed",
8684
"How many slots were missed in this node?")
8785
,("Forge.LastSlot",
88-
"")
86+
"")
8987
]
9088
"nodeCannotForgeNum shows how many times this node could not forge.\
9189
\\nnodeIsLeaderNum shows how many times this node was leader.\
@@ -126,18 +124,22 @@ instance LogFormatting ForgingStats where
126124
, IntM "Forge.NodeIsLeaderNum" (fromIntegral fsNodeIsLeaderNum)
127125
, IntM "Forge.BlocksForgedNum" (fromIntegral fsBlocksForgedNum)
128126
, IntM "Forge.SlotsMissed" (fromIntegral fsSlotsMissedNum)
129-
]
127+
]
130128

131129
emptyForgingStats :: ForgingStats
132130
emptyForgingStats = ForgingStats mempty 0 0 0 0
133131

134-
forgeThreadStats :: Trace IO (Folding (ForgeTracerType blk) ForgingStats)
132+
forgeThreadStats :: Trace IO ForgingStats
135133
-> IO (Trace IO (ForgeTracerType blk))
136-
forgeThreadStats = foldMCondTraceM calculateThreadStats emptyForgingStats
137-
(\case
138-
Left Consensus.TraceStartLeadershipCheck{} -> True
139-
Left _ -> False
140-
Right _ -> True)
134+
forgeThreadStats tr =
135+
let tr' = contramap unfold tr
136+
in foldMCondTraceM calculateThreadStats emptyForgingStats
137+
(\case
138+
Left Consensus.TraceStartLeadershipCheck{} -> True
139+
Left _ -> False
140+
Right _ -> True
141+
)
142+
tr'
141143

142144
calculateThreadStats :: MonadIO m
143145
=> ForgingStats

cardano-node/src/Cardano/Node/Tracing/Tracers/StartLeadershipCheck.hs

+5-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB
3333
import Cardano.Node.Queries (LedgerQueries (..), NodeKernelData (..))
3434
import Cardano.Slotting.Slot (fromWithOrigin)
3535

36-
import Cardano.Ledger.BaseTypes (StrictMaybe (..), fromSMaybe)
36+
import Cardano.Ledger.BaseTypes (StrictMaybe (..))
3737

3838

3939
type ForgeTracerType blk = Either (TraceForgeEvent blk)
@@ -64,16 +64,15 @@ forgeTracerTransform nodeKern (Trace tr) = pure $ Trace $ T.arrow $ T.emit $
6464
<*> nkQueryLedger (ledgerDelegMapSize . ledgerState) nk
6565
<*> nkQueryChain fragmentChainDensity nk)
6666
nodeKern
67-
fromSMaybe
68-
(T.traceWith tr (lc, Right (Left slc)))
69-
(query <&>
70-
\(utxoSize, delegMapSize, chainDensity) ->
67+
case query of
68+
SNothing -> T.traceWith tr (lc, Right (Left slc))
69+
SJust (utxoSize, delegMapSize, chainDensity) ->
7170
let msg = TraceStartLeadershipCheckPlus
7271
slotNo
7372
utxoSize
7473
delegMapSize
7574
(fromRational chainDensity)
76-
in T.traceWith tr (lc, Right (Right msg)))
75+
in T.traceWith tr (lc, Right (Right msg))
7776
(lc, Right a) ->
7877
T.traceWith tr (lc, Right a)
7978
(lc, Left control) ->

cardano-tracer/bench/cardano-tracer-bench.hs

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Cardano.Tracer.Utils
1717
import Cardano.Tracer.Configuration
1818
import Cardano.Tracer.Environment
1919
import Cardano.Tracer.Handlers.Logs.TraceObjects
20+
import Cardano.Tracer.MetaTrace
2021
import Cardano.Tracer.Types
2122

2223
main :: IO ()
@@ -48,6 +49,8 @@ main = do
4849

4950
rtViewPageOpened <- newTVarIO False
5051

52+
tr <- mkTracerTracer $ SeverityF $ Just Warning
53+
5154
let te1 =
5255
TracerEnv
5356
{ teConfig = c1
@@ -65,6 +68,7 @@ main = do
6568
, teProtocolsBrake = protocolsBrake
6669
, teRTViewPageOpened = rtViewPageOpened
6770
, teRTViewStateDir = Nothing
71+
, teTracer = tr
6872
}
6973
te2 =
7074
TracerEnv
@@ -83,6 +87,7 @@ main = do
8387
, teProtocolsBrake = protocolsBrake
8488
, teRTViewPageOpened = rtViewPageOpened
8589
, teRTViewStateDir = Nothing
90+
, teTracer = tr
8691
}
8792

8893
removePathForcibly root

0 commit comments

Comments
 (0)