Skip to content

feat: add migrate gateway fetch and CAR verify - #654

Draft
SgtPooki wants to merge 8 commits into
feat/migrate-1-state-storefrom
feat/migrate-2-fetch-verify
Draft

feat: add migrate gateway fetch and CAR verify#654
SgtPooki wants to merge 8 commits into
feat/migrate-1-state-storefrom
feat/migrate-2-fetch-verify

Conversation

@SgtPooki

Copy link
Copy Markdown
Collaborator

What changed

Part 2 of 5 splitting #652. Fetches each CID as a CAR in one trustless-gateway request (?format=car&dag-scope=all) and verifies the untrusted response in a single pass: every block hash-checked, DAG walked from the requested root for completeness (a truncated response parses cleanly but fails the walk), piece commitment and sha256 computed over the exact bytes landed on disk via temp file + atomic rename. Transport failures map to the resume store's failure categories.

Also moves @ipld/dag-cbor from devDependencies to dependencies: verify-car.ts imports it at runtime, so published installs would fail on any dag-cbor block.

Single-request CAR fetch is deliberate, per-block Helia transport was considered and rejected for now (one request per CID vs thousands for a large DAG). If helia block-brokers grows a streaming CAR transport, this module is the swap point.

How to verify

pnpm install && pnpm run build && pnpm run test:unit -- migrate-verify-car

Notes / risks

Base: feat/migrate-1-state-store. Merge order 1 through 5.

Second slice of the migrate command split (#652). Fetches each CID
as a CAR in one trustless-gateway request (format=car, dag-scope=all)
and verifies the untrusted response in a single pass: every block is
hash-checked, the DAG is walked from the requested root for
completeness, and the piece commitment plus a sha256 are computed
over the exact bytes landed on disk. Failures map to the resume
store's failure categories.

Also moves @ipld/dag-cbor from devDependencies to dependencies:
verify-car imports it at runtime, so published installs would have
failed on any dag-cbor block.
@FilOzzy FilOzzy added team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board. labels Aug 14, 2026
@FilOzzy FilOzzy added this to FOC Aug 14, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Aug 14, 2026
@BigLep BigLep moved this from 📌 Triage to ⌨️ In Progress in FOC Aug 19, 2026
The completeness walk keyed block presence by multihash alone while
links were decoded with the codec the CAR entry declared. A gateway
could serve the root bytes under a raw CID with the same multihash,
omit every child, and pass verification. The walk now records the
arrival codec and rejects any block reached under a different one.

Root matching compares multihashes instead of full CIDs: the
trustless-gateway spec permits answering a CIDv0 request with the
equivalent CIDv1 root, which strict CID equality rejected.

Failure paths now destroy the file sink and cancel the response body
before unlinking (an open handle blocks deletion on Windows and the
fixed temp path then poisons every fallback gateway), buffered sink
writes resolve immediately instead of waiting out each flush, and a
failed block hash reports car_block_mismatch instead of
car_root_mismatch.
Follows the repo convention: human-facing progress goes through
src/utils/cli-logger.ts, not a migrate-private stderr logger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants