ouroboros-consensus icon indicating copy to clipboard operation
ouroboros-consensus copied to clipboard

[FEAT] - checksum when deserializing the ledger snapshot file

Open nfrisby opened this issue 1 year ago • 2 comments

Internal/External Internal

Describe the feature you'd like The deserialization of the ledger snapshot file should fail if what was read from disk differs from what was written to disk (eg disk corruption flipped a bit).

Describe alternatives you've considered This requested feature is not strictly necessary: some interaction with the rest of the network will (eventually) fail if the node has the wrong ledger state. But it could be arbitrarily later, which would be especially confusing. Also, this would limit one of the ubiquitous "possible corruption" explanations for failures (such as VRFKeyBadProof).

Limitation: the checksum would not ensure that the ledger state was serialized to disk correctly---only that the bitstream written to disk was the same read from disk.

nfrisby avatar Jan 18 '24 15:01 nfrisby

@jorisdral had some suggestions about how some utilities from fs-api might help here?

nfrisby avatar Jan 18 '24 16:01 nfrisby

We could use the file read/write functions from System.FS.CRC. They are used by the other storage components already, e.g.,

https://github.com/IntersectMBO/ouroboros-consensus/blob/706c4b162072a4ccf4d484007130f080f5c1a183/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/ImmutableDB/Impl.hs#L500

Now that we're talking about checksums, though it is orthogonal to this issue, the System.FS.CRC module is consensus specific and should probably be moved to consensus instead.

jorisdral avatar Jan 24 '24 10:01 jorisdral