@@ -65,7 +65,7 @@ import Cardano.BM.Trace (traceNamedObject)
65
65
import Cardano.BM.Tracing
66
66
67
67
import Ouroboros.Consensus.Block (BlockConfig , BlockProtocol , CannotForge ,
68
- ConvertRawHash (.. ), ForgeStateInfo , ForgeStateUpdateError , Header , HeaderHash ,
68
+ ConvertRawHash (.. ), ForgeStateInfo , ForgeStateUpdateError , Header ,
69
69
realPointHash , realPointSlot )
70
70
import Ouroboros.Consensus.BlockchainTime (SystemStart (.. ),
71
71
TraceBlockchainTimeEvent (.. ))
@@ -88,8 +88,8 @@ import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
88
88
import Ouroboros.Consensus.Util.Enclose
89
89
90
90
import qualified Ouroboros.Network.AnchoredFragment as AF
91
- import Ouroboros.Network.Block (BlockNo (.. ), ChainHash (.. ), ChainUpdate (.. ),
92
- HasHeader ( .. ), Point , StandardHash , blockNo , pointSlot , unBlockNo )
91
+ import Ouroboros.Network.Block (BlockNo (.. ), ChainUpdate (.. ), HasHeader (.. ), Point ,
92
+ StandardHash , blockNo , pointSlot , unBlockNo )
93
93
import Ouroboros.Network.BlockFetch.ClientState (TraceFetchClientState (.. ),
94
94
TraceLabelPeer (.. ))
95
95
import Ouroboros.Network.BlockFetch.Decision (FetchDecision , FetchDecline (.. ))
@@ -558,7 +558,7 @@ traceChainMetrics (Just _ekgDirect) tForks _blockConfig _fStats tr = do
558
558
Tracer $ \ ev ->
559
559
maybe (pure () ) doTrace (chainTipInformation ev)
560
560
where
561
- chainTipInformation :: ChainDB. TraceEvent blk -> Maybe ( ChainInformation blk )
561
+ chainTipInformation :: ChainDB. TraceEvent blk -> Maybe ChainInformation
562
562
chainTipInformation = \ case
563
563
ChainDB. TraceAddBlockEvent ev -> case ev of
564
564
ChainDB. SwitchedToAFork _warnings newTipInfo oldChain newChain ->
@@ -570,10 +570,10 @@ traceChainMetrics (Just _ekgDirect) tForks _blockConfig _fStats tr = do
570
570
_ -> Nothing
571
571
_ -> Nothing
572
572
573
- doTrace :: ChainInformation blk -> IO ()
573
+ doTrace :: ChainInformation -> IO ()
574
574
doTrace
575
575
ChainInformation { slots, blocks, density, epoch, slotInEpoch, fork, tipBlockHash, tipBlockParentHash, tipBlockIssuerVerificationKeyHash } = do
576
- -- TODO this is executed each time the newFhain changes. How cheap is it?
576
+ -- TODO this is executed each time the newChain changes. How cheap is it?
577
577
meta <- mkLOMeta Critical Public
578
578
579
579
traceD tr meta " density" (fromRational density)
@@ -584,29 +584,19 @@ traceChainMetrics (Just _ekgDirect) tForks _blockConfig _fStats tr = do
584
584
when fork $
585
585
traceI tr meta " forks" =<< STM. modifyReadTVarIO tForks succ
586
586
587
-
588
- let tipBlockHashText :: Text
589
- tipBlockHashText = renderHeaderHash (Proxy @ blk ) tipBlockHash
590
-
591
- tipBlockParentHashText :: Text
592
- tipBlockParentHashText =
593
- renderChainHash
594
- (Text. decodeLatin1 . B16. encode . toRawHash (Proxy @ blk ))
595
- tipBlockParentHash
596
-
597
- tipBlockIssuerVkHashText :: Text
587
+ let tipBlockIssuerVkHashText :: Text
598
588
tipBlockIssuerVkHashText =
599
589
case tipBlockIssuerVerificationKeyHash of
600
590
NoBlockIssuer -> " NoBlockIssuer"
601
591
BlockIssuerVerificationKeyHash bs ->
602
592
Text. decodeLatin1 (B16. encode bs)
603
593
traceNamedObject
604
594
(appendName " tipBlockHash" tr)
605
- (meta, LogMessage tipBlockHashText )
595
+ (meta, LogMessage tipBlockHash )
606
596
607
597
traceNamedObject
608
598
(appendName " tipBlockParentHash" tr)
609
- (meta, LogMessage tipBlockParentHashText )
599
+ (meta, LogMessage tipBlockParentHash )
610
600
611
601
traceNamedObject
612
602
(appendName " tipBlockIssuerVerificationKeyHash" tr)
@@ -1502,7 +1492,7 @@ traceInboundGovernorCountersMetrics (OnOff True) (Just ekgDirect) = ipgcTracer
1502
1492
1503
1493
-- | get information about a chain fragment
1504
1494
1505
- data ChainInformation blk = ChainInformation
1495
+ data ChainInformation = ChainInformation
1506
1496
{ slots :: Word64
1507
1497
, blocks :: Word64
1508
1498
, density :: Rational
@@ -1518,22 +1508,25 @@ data ChainInformation blk = ChainInformation
1518
1508
-- current chain.
1519
1509
, fork :: Bool
1520
1510
-- ^ Was this a fork.
1521
- , tipBlockHash :: HeaderHash blk
1511
+ , tipBlockHash :: Text
1522
1512
-- ^ Hash of the last adopted block.
1523
- , tipBlockParentHash :: ChainHash ( Header blk )
1513
+ , tipBlockParentHash :: Text
1524
1514
-- ^ Hash of the parent block of the last adopted block.
1525
1515
, tipBlockIssuerVerificationKeyHash :: BlockIssuerVerificationKeyHash
1526
1516
-- ^ Hash of the last adopted block issuer's verification key.
1527
1517
}
1528
1518
1529
1519
chainInformation
1530
- :: forall blk . (HasHeader (Header blk ), HasIssuer blk )
1520
+ :: forall blk . ()
1521
+ => HasHeader (Header blk )
1522
+ => HasIssuer blk
1523
+ => ConvertRawHash blk
1531
1524
=> ChainDB. NewTipInfo blk
1532
1525
-> Bool
1533
1526
-> AF. AnchoredFragment (Header blk ) -- ^ Old fragment.
1534
1527
-> AF. AnchoredFragment (Header blk ) -- ^ New fragment.
1535
1528
-> Int64
1536
- -> ChainInformation blk
1529
+ -> ChainInformation
1537
1530
chainInformation newTipInfo fork oldFrag frag blocksUncoupledDelta = ChainInformation
1538
1531
{ slots = unSlotNo $ fromWithOrigin 0 (AF. headSlot frag)
1539
1532
, blocks = unBlockNo $ fromWithOrigin (BlockNo 1 ) (AF. headBlockNo frag)
@@ -1542,8 +1535,8 @@ chainInformation newTipInfo fork oldFrag frag blocksUncoupledDelta = ChainInform
1542
1535
, slotInEpoch = ChainDB. newTipSlotInEpoch newTipInfo
1543
1536
, blocksUncoupledDelta = blocksUncoupledDelta
1544
1537
, fork = fork
1545
- , tipBlockHash = realPointHash (ChainDB. newTipPoint newTipInfo)
1546
- , tipBlockParentHash = AF. headHash oldFrag
1538
+ , tipBlockHash = renderHeaderHash ( Proxy @ blk ) $ realPointHash (ChainDB. newTipPoint newTipInfo)
1539
+ , tipBlockParentHash = renderChainHash ( Text. decodeLatin1 . B16. encode . toRawHash ( Proxy @ blk )) $ AF. headHash oldFrag
1547
1540
, tipBlockIssuerVerificationKeyHash = tipIssuerVkHash
1548
1541
}
1549
1542
where
0 commit comments