IPIP-550: PBNode field ordering - #550
Conversation
🚀 Build Preview on IPFS ready
|
Having `Link` messages before the `Data` message in `PBNode` messages means for HAMT shards you have to read every `Link` before you can process any of them, since the hash type/fanout values used to calculate the prefix each directory entry has is stored in the `Data` field at the end of the message. This IPIP suggests allowing writers to encode the `Data` field first, this allows readers to use streaming parsers that can skip out on reading links if they have already reached the directory entry they are interested in. Further discussion can be found in #533
37fdb60 to
51f16e3
Compare
lidel
left a comment
There was a problem hiding this comment.
Thanks, left some quick first-pass drive-by comments below.
Writing the `Links` first makes reading HAMT data more expensive since, if you are only trying to read a certain path, you have to read all of the `Links` before you can process any of them, as the config needed to calculate the hash prefix length is stored in the `Data` field at the end of the message. Swap the fields round so `Data` can be read before `Links`. Further discussion: ipfs/specs#533 IPIP: ipfs/specs#550
* feat: tests for IPIP-550 PBNode field ordering Gateways must resolve UnixFS content regardless of PBNode field order: the legacy Links-first encoding and the Data-first order proposed for the unixfs-v1-2026 profile. - fixtures: pbnode-field-orders.car, single-entry Directory and HAMTShard in both orders, byte-identical to the IPIP table - tests: path resolution through all four roots, raw block responses byte-exact for all five blocks Refs ipfs/specs#550 * chore: changelog entry under v0.14.1
Make the Data-first ordering opt-in per profile and align the text with DAG-PB codec behavior. - unixfs.md: Profiles registry section with names implementations SHOULD use; both PBNode orderings with reader/writer rules and UnixFS precedence over the legacy DAG-PB codec spec; data-first test vectors in the appendix - ipip-0550: accurate motivation and compatibility, PBNode field order profile parameter (links-first default), two-way security notes, alternatives, fixtures relabeled and linked to tagged gateway-conformance v0.14.1 CARs, working code links
|
Pushed 17444ef and b707207: the ordering is now defined per profile. Does this look sensible @achingbrain? unixfs.md gains a Profiles registry ( Working code in Go:
That makes ratification relatively low-risk: whoever needs the streaming-friendly order can lock it in via the profile, and everyone else, legacy DAGs and libraries included, keeps preexisting behavior. |
…-ordering # Conflicts: # src/unixfs.md
|
Thanks for the updates, all looks good to me. |
Having
Linkmessages before theDatamessage inPBNodemessages means for HAMT shards you have to read everyLinkbefore you can process any of them, since the hash type/fanout values used to calculate the prefix each directory entry has is stored in theDatafield at the end of the message.This IPIP suggests allowing writers to encode the
Datafield first, this allows readers to use streaming parsers that can skip out on reading links if they have already reached the directory entry they are interested in.Further discussion can be found in #533