Piece.from accepts padding larger than the tree (negative size) and heights below 2

Open Beginner friendly
#1,039 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start in piece/parse.ts and check how it validates height and padding before constructing a Piece. The report at report/synapse-core.csv lists failing vectors; compare those cases with the FRC-0069 minimum height and padding bound described in the issue. Done means invalid heights and padding are rejected without producing a negative size or a later .size error.

Written by the indexing model from the issue text.

Description

Running @filoz/synapse-core 0.10.2 against 1,244 PieceCIDv2 vectors generated from the FRC-0069 text (https://github.com/let-the-dreamers-rise/pdp-conform):

  1. Padding larger than the tree is accepted and the size goes negative. Height 2, padding 128 parses and reports raw size -1; height 3, padding 256 gives -2 (38 vectors). PDPVerifier and go-fil-commcid reject these. Any CID read from a provider, an indexer or a URL turns into a negative size with no error.
  2. Heights 0 and 1 parse, and then .size throws undefined must be positive (30 vectors). The FRC minimum is 2.
  3. Padding that doesn't follow the minimal-tree rule is accepted (74 vectors, e.g. 127 bytes as padding 127 at height 3). PDPVerifier accepts some of these too (asked in FilOzone/pdp), so this one may be policy.
  4. Sizes above Number.MAX_SAFE_INTEGER throw (247 vectors). Safe, but valid CIDs are rejected. A bigint size would cover them.

CommP computation is correct: 930 of 930 payloads (0 B to 1 MiB, edge sizes) match the reference.

Suggested fix for 1 and 2: in piece/parse.ts, reject height < 2 and padding > 127 * 2^(height-2). Per-vector results: report/synapse-core.csv. Happy to open the PR.


Generated by Claude Code

Dominant language
TypeScript
Stars
27
Forks
35
Avg merge
1d 13h
Merged PRs (30d)
38

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FilOzone/synapse-sdk

All issues in FilOzone/synapse-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.