Skip to content

Commit

Permalink
Integrate ledger snapshot checksum
Browse files Browse the repository at this point in the history
- Categorise `LedgerDB.SnapshotMissingChecksum` trace as `Warning`
- Temporary override `ouroboros-consensus` in `cabal.project`
  • Loading branch information
geo2a committed Dec 4, 2024
1 parent 36871ba commit 3ce2379
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,16 @@ allow-newer:
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.
source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
-- use branch geo2a/issue-892-checksum-snaphot-file-release-ouroboros-consensus-0.21.0.0-backport
tag: 0ff4c0445
--sha256: xWBEq9kq2eUTlOnMBkSftH8NUUGbpwpamu1G1TgGETU=
subdir:
ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-diffusion
ouroboros-consensus-protocol
sop-extras
strict-sop-core
11 changes: 11 additions & 0 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,8 @@ instance ( StandardHash blk
" This is most likely an expected change in the serialization format,"
<> " which currently requires a chain replay"
_ -> ""
forHuman (LedgerDB.SnapshotMissingChecksum snap) =
"Checksum file is missing for snapshot " <> showT snap

forMachine dtals (LedgerDB.TookSnapshot snap pt enclosedTiming) =
mconcat [ "kind" .= String "TookSnapshot"
Expand All @@ -1535,15 +1537,21 @@ instance ( StandardHash blk
mconcat [ "kind" .= String "InvalidSnapshot"
, "snapshot" .= forMachine dtals snap
, "failure" .= show failure ]
forMachine dtals (LedgerDB.SnapshotMissingChecksum snap) =
mconcat [ "kind" .= String "SnapshotMissingChecksum"
, "snapshot" .= forMachine dtals snap
]

instance MetaTrace (LedgerDB.TraceSnapshotEvent blk) where
namespaceFor LedgerDB.TookSnapshot {} = Namespace [] ["TookSnapshot"]
namespaceFor LedgerDB.DeletedSnapshot {} = Namespace [] ["DeletedSnapshot"]
namespaceFor LedgerDB.InvalidSnapshot {} = Namespace [] ["InvalidSnapshot"]
namespaceFor LedgerDB.SnapshotMissingChecksum {} = Namespace [] ["SnapshotMissingChecksum"]

severityFor (Namespace _ ["TookSnapshot"]) _ = Just Info
severityFor (Namespace _ ["DeletedSnapshot"]) _ = Just Debug
severityFor (Namespace _ ["InvalidSnapshot"]) _ = Just Error
severityFor (Namespace _ ["SnapshotMissingChecksum"]) _ = Just Warning
severityFor _ _ = Nothing

documentFor (Namespace _ ["TookSnapshot"]) = Just $ mconcat
Expand All @@ -1555,12 +1563,15 @@ instance MetaTrace (LedgerDB.TraceSnapshotEvent blk) where
"A snapshot was deleted from the disk."
documentFor (Namespace _ ["InvalidSnapshot"]) = Just
"An on disk snapshot was invalid. Unless it was suffixed, it will be deleted"
documentFor (Namespace _ ["SnapshotMissingChecksum"]) = Just
"Checksum file was missing for snapshot."
documentFor _ = Nothing

allNamespaces =
[ Namespace [] ["TookSnapshot"]
, Namespace [] ["DeletedSnapshot"]
, Namespace [] ["InvalidSnapshot"]
, Namespace [] ["SnapshotMissingChecksum"]
]


Expand Down
7 changes: 7 additions & 0 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ instance HasSeverityAnnotation (ChainDB.TraceEvent blk) where
LedgerDB.TookSnapshot {} -> Info
LedgerDB.DeletedSnapshot {} -> Debug
LedgerDB.InvalidSnapshot {} -> Error
LedgerDB.SnapshotMissingChecksum {} -> Warning

getSeverityAnnotation (ChainDB.TraceCopyToImmutableDBEvent ev) = case ev of
ChainDB.CopiedBlockToImmutableDB {} -> Debug
Expand Down Expand Up @@ -615,6 +616,8 @@ instance ( ConvertRawHash blk
" This is most likely an expected change in the serialization format,"
<> " which currently requires a chain replay"
_ -> ""
LedgerDB.SnapshotMissingChecksum snap ->
"Checksum file is missing for snapshot " <> showT snap

LedgerDB.TookSnapshot snap pt RisingEdge ->
"Taking ledger snapshot " <> showT snap <>
Expand Down Expand Up @@ -1101,6 +1104,10 @@ instance ( ConvertRawHash blk
mconcat [ "kind" .= String "TraceSnapshotEvent.InvalidSnapshot"
, "snapshot" .= toObject verb snap
, "failure" .= show failure ]
LedgerDB.SnapshotMissingChecksum snap ->
mconcat [ "kind" .= String "TraceSnapshotEvent.SnapshotMissingChecksum"
, "snapshot" .= toObject verb snap
]

toObject verb (ChainDB.TraceCopyToImmutableDBEvent ev) = case ev of
ChainDB.CopiedBlockToImmutableDB pt ->
Expand Down

0 comments on commit 3ce2379

Please sign in to comment.