IPNS: clarify serialization and the type of ValidityType, TTL and Seq fields
- Dominant language
- HTML
- Stars
- 1.2k
- Forks
- 247
- Avg merge
- 5d 21h
- Merged PRs (30d)
- 4
Description
## Problem
IPNS Record spec lists Validity, TTL and Seq as uint64:
- https://specs.ipfs.tech/ipns/ipns-record/#ttl-uint64
- https://specs.ipfs.tech/ipns/ipns-record/#sequence-uint64
- https://specs.ipfs.tech/ipns/ipns-record/#validity-type-uint64
..but this only applies to the protobuf fields from IPNS v1.
For wider background, documentation and cleanup of v1 vs v2 was done in #319, #376.
In IPNS v2 we store values in DAG-CBOR map in Data field, and fields like the TTL read from v2 `Data` field (DAG-CBOR) is represented as `int64` (see [boxo/ipns code](https://github.com/ipfs/boxo/blob/b101ba0858150cd6a34b6cb68eefd28c411bd58c/ipns/record.go#L143-L149)).
In other words, in GO impl. `time.Duration` is represented as `int64`, and that is how "uint64" fields like TTL are stored in v2 Data field (CBOR). This is also confirmed by the way IPLD data model impl. at [go-ipld-prime/node/basic](https://github.com/ipld/go-ipld-prime/blob/198d7dba8fb83cf9e6c1da74d7800cb300c66433/node/basic/deprecated.go#L24C19-L24C24) works.
## Solution
Ideas welcome. My initial idea is to move away from go specific.
Clarify this in the IPFS specification and mark these fields as language-agnostic `integer` and then add bullet points in their respective section that when represented in legacy v1, the type for protobuf is `uint64`, and when represented in v2 (dag-cbor) it is `int64`.
cc @2color as you've been working with TTL in JS recently.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.