Skip to content

Commit ccde6bd

Browse files
committed
TSLCP: Chain density
1 parent b311bbc commit ccde6bd

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ instance LogFormatting TraceStartLeadershipCheckPlus where
15161516
, "slot" .= toJSON (unSlotNo tsSlotNo)
15171517
, "utxoSize" .= Number (fromIntegral tsUtxoSize)
15181518
, "delegMapSize" .= Number (fromIntegral tsDelegMapSize)
1519-
, "chainDensity" .= Number (fromRational (toRational tsChainDensity))
1519+
, "chainDensity" .= (toJSON tsChainDensity)
15201520
]
15211521
forHuman TraceStartLeadershipCheckPlus {..} =
15221522
"Checking for leadership in slot " <> showT (unSlotNo tsSlotNo)

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ forgeTracerTransform nodeKern (Trace tr) =
7676
slotNo
7777
utxoSize
7878
delegMapSize
79-
(fromRational chainDensity)
79+
chainDensity
8080
in pure (lc, Right (Right msg))
8181
(lc, Right a) ->
8282
pure (lc, Right a)
@@ -96,12 +96,12 @@ fragmentChainDensity ::
9696
#else
9797
AF.HasHeader (Header blk)
9898
#endif
99-
=> AF.AnchoredFragment (Header blk) -> Rational
99+
=> AF.AnchoredFragment (Header blk) -> Double
100100
fragmentChainDensity frag = calcDensity blockD slotD
101101
where
102-
calcDensity :: Word64 -> Word64 -> Rational
102+
calcDensity :: Word64 -> Word64 -> Double
103103
calcDensity bl sl
104-
| sl > 0 = toRational bl / toRational sl
104+
| sl > 0 = fromIntegral bl / fromIntegral sl
105105
| otherwise = 0
106106
slotN = unSlotNo $ fromWithOrigin 0 (AF.headSlot frag)
107107
-- Slot of the tip - slot @k@ blocks back. Use 0 as the slot for genesis

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ traceChainMetrics (Just _ekgDirect) tForks _blockConfig _fStats tr = do
666666
-- TODO this is executed each time the newChain changes. How cheap is it?
667667
meta <- mkLOMeta Critical Public
668668

669-
traceD tr meta "density" (fromRational density)
669+
traceD tr meta "density" density
670670
traceI tr meta "slotNum" slots
671671
traceI tr meta "blockNum" blocks
672672
traceI tr meta "slotInEpoch" slotInEpoch
@@ -1103,7 +1103,7 @@ traceLeadershipChecks _ft nodeKern _tverb tr = Tracer $
11031103
\(utxoSize, delegMapSize, chainDensity) ->
11041104
[ ("utxoSize", toJSON utxoSize)
11051105
, ("delegMapSize", toJSON delegMapSize)
1106-
, ("chainDensity", toJSON (fromRational chainDensity :: Float))
1106+
, ("chainDensity", toJSON chainDensity)
11071107
])
11081108
)
11091109
_ -> pure ()
@@ -1716,7 +1716,7 @@ traceInboundGovernorCountersMetrics (OnOff True) (Just ekgDirect) = ipgcTracer
17161716
data ChainInformation = ChainInformation
17171717
{ slots :: Word64
17181718
, blocks :: Word64
1719-
, density :: Rational
1719+
, density :: Double
17201720
-- ^ the actual number of blocks created over the maximum expected number
17211721
-- of blocks that could be created over the span of the last @k@ blocks.
17221722
, epoch :: EpochNo
@@ -1772,12 +1772,12 @@ chainInformation selChangedInfo fork oldFrag frag blocksUncoupledDelta = ChainIn
17721772

17731773
fragmentChainDensity ::
17741774
HasHeader (Header blk)
1775-
=> AF.AnchoredFragment (Header blk) -> Rational
1775+
=> AF.AnchoredFragment (Header blk) -> Double
17761776
fragmentChainDensity frag = calcDensity blockD slotD
17771777
where
1778-
calcDensity :: Word64 -> Word64 -> Rational
1778+
calcDensity :: Word64 -> Word64 -> Double
17791779
calcDensity bl sl
1780-
| sl > 0 = toRational bl / toRational sl
1780+
| sl > 0 = fromIntegral bl / fromIntegral sl
17811781
| otherwise = 0
17821782
slotN = unSlotNo $ fromWithOrigin 0 (AF.headSlot frag)
17831783
-- Slot of the tip - slot @k@ blocks back. Use 0 as the slot for genesis

0 commit comments

Comments
 (0)