Skip to content

feat: verify node hashes on read#1516

Draft
demosdemon wants to merge 1 commit intomainfrom
brandon.leblanc/check-hash-on-read
Draft

feat: verify node hashes on read#1516
demosdemon wants to merge 1 commit intomainfrom
brandon.leblanc/check-hash-on-read

Conversation

@demosdemon
Copy link
Contributor

@demosdemon demosdemon commented Dec 9, 2025

When we read nodes from storage, we currently assume the data is consistent and return it as-is to the caller. However, that is a bad assumption as data on disk can easily be corrupted. As an extreme example, cosmic background radiation can cause bit flips for non-ECC hardware. And as a more realistic example, there could be a bug in Firewood that causes data to be overwritten or serialized incorrectly.

This change adds verifying reads to the database, with two exceptions. Reading the root upon opening the database is unable to verify the root hash. Unless we're running with a root store, the root hash will be unknown to firewood on startup. This likely means we should include the root hash in the header. I will revisit that soon. Additionally, reading leaked areas via the fsck util is unable to verify the hash; which is to be expected for a leaked area.

@demosdemon demosdemon force-pushed the brandon.leblanc/check-hash-on-read branch 3 times, most recently from d1debb0 to b148409 Compare December 9, 2025 07:17
@demosdemon demosdemon force-pushed the brandon.leblanc/check-hash-on-read branch from e11e12b to 1d72261 Compare December 11, 2025 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant