Skip to content

Commit b472efd

Browse files
committed
TSLCP: Chain density
1 parent e078e3d commit b472efd

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ instance LogFormatting TraceStartLeadershipCheckPlus where
14701470
, "slot" .= toJSON (unSlotNo tsSlotNo)
14711471
, "utxoSize" .= Number (fromIntegral tsUtxoSize)
14721472
, "delegMapSize" .= Number (fromIntegral tsDelegMapSize)
1473-
, "chainDensity" .= Number (fromRational (toRational tsChainDensity))
1473+
, "chainDensity" .= (toJSON tsChainDensity)
14741474
]
14751475
forHuman TraceStartLeadershipCheckPlus {..} =
14761476
"Checking for leadership in slot " <> showT (unSlotNo tsSlotNo)

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

Lines changed: 4 additions & 4 deletions
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)
@@ -97,12 +97,12 @@ fragmentChainDensity ::
9797
#else
9898
AF.HasHeader (Header blk)
9999
#endif
100-
=> AF.AnchoredFragment (Header blk) -> Rational
100+
=> AF.AnchoredFragment (Header blk) -> Double
101101
fragmentChainDensity frag = calcDensity blockD slotD
102102
where
103-
calcDensity :: Word64 -> Word64 -> Rational
103+
calcDensity :: Word64 -> Word64 -> Double
104104
calcDensity bl sl
105-
| sl > 0 = toRational bl / toRational sl
105+
| sl > 0 = fromIntegral bl / fromIntegral sl
106106
| otherwise = 0
107107
slotN = unSlotNo $ fromWithOrigin 0 (AF.headSlot frag)
108108
-- Slot of the tip - slot @k@ blocks back. Use 0 as the slot for genesis

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ traceChainMetrics (Just _ekgDirect) tForks _blockConfig _fStats tr = do
645645
-- TODO this is executed each time the newChain changes. How cheap is it?
646646
meta <- mkLOMeta Critical Public
647647

648-
traceD tr meta "density" (fromRational density)
648+
traceD tr meta "density" density
649649
traceI tr meta "slotNum" slots
650650
traceI tr meta "blockNum" blocks
651651
traceI tr meta "slotInEpoch" slotInEpoch
@@ -1082,7 +1082,7 @@ traceLeadershipChecks _ft nodeKern _tverb tr = Tracer $
10821082
\(utxoSize, delegMapSize, chainDensity) ->
10831083
[ ("utxoSize", toJSON utxoSize)
10841084
, ("delegMapSize", toJSON delegMapSize)
1085-
, ("chainDensity", toJSON (fromRational chainDensity :: Float))
1085+
, ("chainDensity", toJSON chainDensity)
10861086
])
10871087
)
10881088
_ -> pure ()
@@ -1693,7 +1693,7 @@ traceInboundGovernorCountersMetrics (OnOff True) (Just ekgDirect) = ipgcTracer
16931693
data ChainInformation = ChainInformation
16941694
{ slots :: Word64
16951695
, blocks :: Word64
1696-
, density :: Rational
1696+
, density :: Double
16971697
-- ^ the actual number of blocks created over the maximum expected number
16981698
-- of blocks that could be created over the span of the last @k@ blocks.
16991699
, epoch :: EpochNo
@@ -1749,12 +1749,12 @@ chainInformation selChangedInfo fork oldFrag frag blocksUncoupledDelta = ChainIn
17491749

17501750
fragmentChainDensity ::
17511751
HasHeader (Header blk)
1752-
=> AF.AnchoredFragment (Header blk) -> Rational
1752+
=> AF.AnchoredFragment (Header blk) -> Double
17531753
fragmentChainDensity frag = calcDensity blockD slotD
17541754
where
1755-
calcDensity :: Word64 -> Word64 -> Rational
1755+
calcDensity :: Word64 -> Word64 -> Double
17561756
calcDensity bl sl
1757-
| sl > 0 = toRational bl / toRational sl
1757+
| sl > 0 = fromIntegral bl / fromIntegral sl
17581758
| otherwise = 0
17591759
slotN = unSlotNo $ fromWithOrigin 0 (AF.headSlot frag)
17601760
-- Slot of the tip - slot @k@ blocks back. Use 0 as the slot for genesis

0 commit comments

Comments
 (0)