IntersectMBO / ouroboros-consensus

Implementation of a Consensus Layer for the Ouroboros family of protocols
https://ouroboros-consensus.cardano.intersectmbo.org
Apache License 2.0
34 stars 23 forks source link

[FEAT] - checksum when deserializing the ledger snapshot file #892

Open nfrisby opened 9 months ago

nfrisby commented 9 months ago

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 commented 9 months ago

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

jorisdral commented 9 months ago

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.