Repository navigation
fix(core): drop sync-multihash-sha2 and align piece size limits with commp-wasm - #1152
Open
hugomrdias wants to merge 1 commit into
Open
hugomrdias wants to merge 1 commit into
hugomrdias wants to merge 1 commit into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
filecoin-encryption-envelope
@filoz/keysmith
@filoz/synapse-core
@filoz/synapse-react
@filoz/synapse-sdk
commit: |
Contributor
|
Docs preview: https://pr-1152-synapse-dev.filoz.workers.dev Built from 148e54f. |
…commp-wasm Use ox's synchronous Hash.sha256 for Piece.merkle.computeNode instead of sync-multihash-sha2, whose ./sha256 export has no default condition and whose node build imports node:crypto. PieceCID hashing already goes through commp-wasm, so merkle helpers were the only consumer. Piece.MAX_SIZE now re-exports commp-wasm's MAX_PAYLOAD_SIZE (127 * 2^47 bytes) instead of the height-255 bound the hasher rejects, and Piece.MAX_HEIGHT is derived from it (49 instead of 255). Also remove the unused merkle split() helper and a stale zero-comm comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hugomrdias
force-pushed
the
hugomrdias/sync-multihash-sha2-core-3a177d
branch
from
November 20, 2026 19:26
bd226ab to
148e54f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sync-multihash-sha2.Piece.merkle.computeNodenow usesHash.sha256fromox, which is synchronous and already a core dependency (it uses@noble/hashesunderneath).ROOT_SIZEis now the literal32.Piece.MAX_SIZEnow matches the hasher. It re-exportscommp-wasm'sMAX_PAYLOAD_SIZE(127n << 47n, about 15.9 PiB). It used to be a height-255 value (about 2^255 bytes).Piece.MAX_HEIGHTis derived fromMAX_SIZE.heightFor(MAX_SIZE)gives 49. It used to be 255.split()frominternal/merkle.tsand fixed an outdated comment inzero-comm.ts.Why
PieceCID hashing (
calculate,hasher,transformStream) already goes throughcommp-wasm. The only remaining user ofsync-multihash-sha2was the publicPiece.merklehelpers, and nothing in the repo calls those outside tests. The package also has two problems:./sha256export only definesbrowserandnodeconditions, with nodefault. Runtimes that match neither (for example some worker setups) can't resolve it.nodebuild importsnode:crypto.The old
MAX_SIZEwas larger than anythingcalculateaccepts. A size that passed a check againstMAX_SIZEcould still make the hasher throw aRangeError.commp-wasmcaps the size at127 × 2^47so that padding and piece size stay exact as JS numbers.Reviewer notes
MAX_SIZEandMAX_HEIGHTare public constants and their values change. I've marked this as afixbecause the old values were limits callers could never actually reach.docs/will pick up the new values when they're regenerated.test/piece.test.ts. The existingcomputeNodeandzeroRootvectors pass withox. Core node and browser suites pass.🤖 Generated with Claude Code