@@ -8,7 +8,7 @@ module Cardano.Node.Tracing.Tracers.BlockReplayProgress
8
8
import Cardano.Api (textShow )
9
9
10
10
import Cardano.Logging
11
- import Ouroboros.Consensus.Block (realPointSlot )
11
+ import Ouroboros.Consensus.Block (SlotNo , realPointSlot )
12
12
import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB
13
13
import qualified Ouroboros.Consensus.Storage.LedgerDB as LedgerDB
14
14
import Ouroboros.Network.Block (pointSlot , unSlotNo )
@@ -20,12 +20,14 @@ import Data.Text (pack)
20
20
21
21
data ReplayBlockStats = ReplayBlockStats
22
22
{ rpsDisplay :: Bool
23
+ , rpsCurSlot :: SlotNo
24
+ , rpsGoalSlot :: SlotNo
23
25
, rpsProgress :: Double
24
26
, rpsLastProgress :: Double
25
27
}
26
28
27
29
emptyReplayBlockStats :: ReplayBlockStats
28
- emptyReplayBlockStats = ReplayBlockStats False 0.0 0.0
30
+ emptyReplayBlockStats = ReplayBlockStats False 0 0 0 .0 0.0
29
31
30
32
--------------------------------------------------------------------------------
31
33
-- ReplayBlockStats Tracer
@@ -37,7 +39,15 @@ instance LogFormatting ReplayBlockStats where
37
39
[ " kind" .= String " ReplayBlockStats"
38
40
, " progress" .= String (pack $ show rpsProgress)
39
41
]
40
- forHuman ReplayBlockStats {.. } = " Block replay progress " <> textShow rpsProgress <> " %"
42
+ forHuman ReplayBlockStats {.. } = " Replayed block: slot " <> textShow (unSlotNo rpsCurSlot) <> " out of " <> textShow (unSlotNo rpsGoalSlot) <> " . Progress: " <> textShow (round2 rpsProgress) <> " %"
43
+ where
44
+ round2 :: Double -> Double
45
+ round2 num =
46
+ let
47
+ f :: Int
48
+ f = round $ num * 100
49
+ in fromIntegral f / 100
50
+
41
51
asMetrics ReplayBlockStats {.. } =
42
52
[DoubleM " blockReplayProgress" rpsProgress]
43
53
@@ -77,12 +87,12 @@ replayBlockStats ReplayBlockStats {..} _context
77
87
(ChainDB. TraceLedgerDBEvent
78
88
(LedgerDB. LedgerReplayEvent
79
89
(LedgerDB. TraceReplayProgressEvent
80
- (LedgerDB. ReplayedBlock pt [] (LedgerDB. ReplayStart replayTo) _ )))) = do
81
- let slotno = toInteger $ unSlotNo ( realPointSlot pt)
82
- endslot = toInteger $ withOrigin 0 unSlotNo ( pointSlot replayTo)
83
- progress' = (fromInteger slotno * 100.0 ) / fromInteger ( max slotno endslot)
90
+ (LedgerDB. ReplayedBlock pt [] _ (LedgerDB. ReplayGoal replayTo))))) = do
91
+ let slotno = realPointSlot pt
92
+ endslot = withOrigin 0 id $ pointSlot replayTo
93
+ progress' = (fromIntegral (unSlotNo slotno) * 100.0 ) / fromIntegral (unSlotNo $ max slotno endslot)
84
94
pure $ if (progress' == 0.0 && not rpsDisplay)
85
- || ((progress' - rpsLastProgress) > 1.0 )
86
- then ReplayBlockStats True progress' progress'
87
- else ReplayBlockStats False progress' rpsLastProgress
95
+ || ((progress' - rpsLastProgress) > 0.1 )
96
+ then ReplayBlockStats True slotno endslot progress' progress'
97
+ else ReplayBlockStats False slotno endslot progress' rpsLastProgress
88
98
replayBlockStats st@ ReplayBlockStats {} _context _ = pure st
0 commit comments