Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates static assert of cache hash data Header size #2039

Merged

Conversation

brooksprumo
Copy link

Problem

The account hash cache data file contains a header with the number of entries in the file. The count itself is a usize. Since we are writing this to disk, we annotate the struct with repr(C), but usize does not have a fixed binary size. If somehow we tried to mix a 32-bit and 64-bit system, the header's count would be interpreted wrong.

Summary of Changes

Add a static assert that the size of the header is 8 bytes.

This is an easy fix to ensure binary compatibility is not broken, and doesn't require refactoring types more broadly (which can still be done in a subsequent PR).

@brooksprumo brooksprumo self-assigned this Jul 8, 2024
@brooksprumo brooksprumo marked this pull request as ready for review July 8, 2024 20:11
@brooksprumo brooksprumo requested a review from HaoranYi July 8, 2024 20:12
Copy link

@HaoranYi HaoranYi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@brooksprumo brooksprumo merged commit 8c53bc5 into anza-xyz:master Jul 8, 2024
40 checks passed
@brooksprumo brooksprumo deleted the cache-hash-data-header-size branch July 8, 2024 21:24
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.

2 participants