Skip to content

fix non-deterministic piece CID for inline DAG regeneration#657

Merged
parkan merged 1 commit intomainfrom
fix/daggen-deterministic-block-order
Apr 10, 2026
Merged

fix non-deterministic piece CID for inline DAG regeneration#657
parkan merged 1 commit intomainfrom
fix/daggen-deterministic-block-order

Conversation

@parkan
Copy link
Copy Markdown
Collaborator

@parkan parkan commented Apr 10, 2026

UnmarshalToBlocks iterated data.Reals and data.Additional via 'for c, d := range', and Go map iteration order is randomized per-instance. The same serialized directory blob therefore yielded a different block sequence on each call, producing a different CAR byte layout and a different piece CID even though the root CID was stable.

Sort the CIDs lexicographically before iterating so the CAR layout is content-derived and reproducible. Add a regression test that asserts the same marshaled blob unmarshals to the same block order across repeated calls.

Reported by users seeing baga6ea4...drift across consecutive 'dag generate' runs against the same inline preparation.

UnmarshalToBlocks iterated data.Reals and data.Additional via 'for c, d :=
range', and Go map iteration order is randomized per-instance. The same
serialized directory blob therefore yielded a different block sequence on
each call, producing a different CAR byte layout and a different piece CID
even though the root CID was stable.

Sort the CIDs lexicographically before iterating so the CAR layout is
content-derived and reproducible. Add a regression test that asserts the
same marshaled blob unmarshals to the same block order across repeated
calls.

Reported by users seeing baga6ea4...drift across consecutive 'dag generate'
runs against the same inline preparation.
@parkan parkan marked this pull request as ready for review April 10, 2026 11:24
@parkan parkan merged commit 10be18d into main Apr 10, 2026
1 check passed
@parkan parkan deleted the fix/daggen-deterministic-block-order branch April 10, 2026 11:56
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.

1 participant