Skip to content

use u64 rather than usize in file hashing paths#485

Merged
assafvayner merged 2 commits intomainfrom
assaf/file-hash-with-u64
Sep 8, 2025
Merged

use u64 rather than usize in file hashing paths#485
assafvayner merged 2 commits intomainfrom
assaf/file-hash-with-u64

Conversation

@assafvayner
Copy link
Contributor

Using the file hashing components in WASM found a bug that using 32 but usize causes errors when hashing the file.

This PR enforces the use of u64 everywhere along that path (and also pins the wasm-bindgen version)

@seanses
Copy link
Collaborator

seanses commented Sep 8, 2025

Our chunk size can never exceed u32::MAX because there's a upper limit at 128 KiB, why are these causing problems?

@assafvayner
Copy link
Contributor Author

Our chunk size can never exceed u32::MAX because there's a upper limit at 128 KiB, why are these causing problems?

The issue isn't with the chunk size, it's with the sizes of "segment" cuts made in the aggregated node hash computation. I went the simple route and just changed everything to u64 rather than only the particular piece. Is this a non-negotiable? we can keep u32 around with some extra work to convert when it matters.

// extern "C" {
// #[wasm_bindgen(js_namespace = console)]
// fn log(s: &str);
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be commented?

Copy link
Contributor Author

@assafvayner assafvayner Sep 8, 2025

Choose a reason for hiding this comment

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

yes, we do not log anything in the thin wasm right now.

It is extern "C" but really this is importing JS functionality

@hoytak
Copy link
Collaborator

hoytak commented Sep 8, 2025

LGTM

Copy link
Collaborator

@hoytak hoytak left a comment

Choose a reason for hiding this comment

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

Approving

@assafvayner assafvayner merged commit e01896e into main Sep 8, 2025
10 of 11 checks passed
@assafvayner assafvayner deleted the assaf/file-hash-with-u64 branch September 8, 2025 21:27
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.

3 participants