Skip to content

Commit 433bd0c

Browse files
committed
Refine and use CIDsV1
1 parent 9c1084a commit 433bd0c

File tree

1 file changed

+39
-30
lines changed

1 file changed

+39
-30
lines changed

docs/concepts/ipns.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ Because PubSub doesn't have the notion of persistence (messages are ephemeral an
9898

9999
In Kubo, IPNS over PubSub is not enabled by default and can be enabled using the [`Ipns.UsePubsub`](https://github.com/ipfs/kubo/blob/master/docs/config.md#ipnsusepubsub) configuration.
100100

101-
Initial operations, e.g. resolving or publishing an IPNS name for the first time can take time as they involve a roundtrip to the DHT (to lookup or publish provider records for the topic). After the subscription to the topic is established, PubSub usually improves both publishing and resolving times of IPNS by relying on interested peers for both operations.
101+
Initial operations, e.g. resolving or publishing an IPNS name for the first time can take time as they involve a roundtrip to the DHT (to lookup or publish provider records for the topic).
102102

103-
It should be noted that there's an upper limit to the number of unique IPNS names you can resolve over PubSub, because for each name, a subscription is created which requires several open network connections for the mesh peer.
103+
After the subscription to the topic is established, PubSub usually improves both publishing and resolving times of IPNS by relying on interested peers for both operations.
104+
105+
It should be noted that there's an upper limit to the number of unique IPNS names you can resolve over PubSub, because for each name, a subscription is created which opens several network connections to mesh peers.
104106

105107
##### Publishing IPNS records over PubSub lifecycle
106108

@@ -111,6 +113,8 @@ It should be noted that there's an upper limit to the number of unique IPNS name
111113
5. Whenever [a new peer joins the topic](https://github.com/libp2p/go-libp2p-pubsub-router/blob/292d99457d224853706c5e49f8ddc112740a856a/pubsub.go#L538-L560) (specifically your peer mesh), ask them for the record. If they respond with a newer record, update it locally and publish the updated record to the.
112114
6. Periodically (by default every 10 minutes) rebroadcast the IPNS record,
113115

116+
Steps 5 and 6 describe from a high level how IPNS record persistence is layered over PubSub by ensuring continuous propagation of the IPNS record in the face of node churn (nodes dropping in and out of the network).
117+
114118
### Tradeoffs between consistency vs. availability
115119

116120
The self-certifying nature of IPNS comes with an inherent tradeoff between **consistency** and **availability**.
@@ -119,32 +123,37 @@ Consistency means ensuring that users resolve to the latest published IPNS recor
119123

120124
Availability means resolving to a valid IPNS record, at the cost of potentially resolving to an outdated record.
121125

122-
#### IPNS record validity tradeoffs
126+
#### IPNS record validity
123127

124128
When setting the `validity` (referred to as [`lifetime` by Kubo](https://github.com/ipfs/kubo/blob/master/docs/config.md#ipnsrecordlifetime)) field of an IPNS record, you typically need to choose whether you favor **consistency** (short validity period, e.g. 24 hours) or **availability** (long validity period, e.g. 1 month), due to the inherent trade-off between the two.
125129

130+
#### Practical considerations
131+
132+
One of the most important things to consider with IPNS names is **how frequently you intend on updating the name**.
133+
134+
Practically, two levers within your control determine where your IPNS name is on the spectrum between consistency and availability:
135+
136+
- **IPNS record validity:** longer validity will veer towards availability. Moreover, longer validity will reduce the dependence on the keyholder (which for most purposes is stored on a single machine and rare shared) since the record can continue to persist without requiring the private key holder to sign a new record. Another benefit of a longer validity is that the transport can be delegated to other nodes or services (such as [w3name](https://staging.web3.storage/docs/how-tos/w3name/)), without compromising the private key.
137+
- **Transport mechanism:** the DHT veers towards consistency while PubSub veers towards availability. However, with Kubo, IPNS names are always published to the DHT, while PubSub is opt-in. For most purposes, enabling PubSub is a net gain unless you hit the upper limit of connections as a result of too many PubSub subscriptions.
138+
126139
## IPNS in practice
127140

128-
### IPNS names can be resolved using IPFS gateways
141+
### Resolving IPNS names using IPFS gateways
129142

130143
IPNS names can be resolved by [IPFS gateways](ipfs-gateway.md) in a _trusted_ fashion using both path resolution and subdomain resolution style:
131144

132145
- Path resolution: `https://ipfs.io/ipns/{ipns-name}`
133146
- Subdomain resolution: `https://{ipns-name}.ipns.dweb.link`
134147

135-
> **Note** IPNS resolution via an IPFS gateway is **trusted** which means you delegate IPNS resolution to the gateway without any means to verify the response you get, i.e the content path and signature of the IPNS record.
148+
For example:
149+
- [https://ipfs.io/ipns/k51qzi5uqu5dlvj2baxnqndepeb86cbk3ng7n3i46uzyxzyqj2xjonzllnv0v8](https://ipfs.io/ipns/k51qzi5uqu5dlvj2baxnqndepeb86cbk3ng7n3i46uzyxzyqj2xjonzllnv0v8)
136150

137-
<!-- ### Third-party providing/publishing w3name -->
138-
139-
## Example
151+
> **Note** IPNS resolution via an IPFS gateway is **trusted** (in the sense of trusting the gateway) which means you delegate IPNS resolution to the gateway without any means to verify the authenticity response you get, i.e the content path and signature of the IPNS record.
140152
141-
When looking up an IPNS address, use the `/ipns/` prefix:
153+
<!-- ### Third-party providing/publishing w3name -->
142154

143-
```shell
144-
/ipns/QmSrPmbaUKA3ZodhzPWZnpFgcPMFWF4QsxXbkWfEptTBJd
145-
```
146155

147-
## Example IPNS Setup with CLI
156+
## Publishing IPNS names with Kubo
148157

149158
1. Start your IPFS daemon, if it isn't already running:
150159

@@ -161,9 +170,9 @@ When looking up an IPNS address, use the `/ipns/` prefix:
161170
1. Add your file to IPFS:
162171

163172
```shell
164-
ipfs add hello.txt
173+
ipfs add --cid-version 1 hello.txt
165174

166-
> added QmUVTKsrYJpaxUT7dr9FpKq6AoKHhEM7eG1ZHGL56haKLG hello.txt
175+
> added bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 hello.txt
167176
> 11 B / 11 B [=====================================================] 100.00%
168177
```
169178

@@ -172,25 +181,25 @@ When looking up an IPNS address, use the `/ipns/` prefix:
172181
1. Use `cat` and the CID you just got from IPFS to view the file again:
173182

174183
```shell
175-
ipfs cat QmUVTKsrYJpaxUT7dr9FpKq6AoKHhEM7eG1ZHGL56haKLG
184+
ipfs cat bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244
176185

177186
> Hello IPFS
178187
```
179188

180189
1. Publish your CID to IPNS:
181190

182191
```shell
183-
ipfs name publish /ipfs/QmUVTKsrYJpaxUT7dr9FpKq6AoKHhEM7eG1ZHGL56haKLG
192+
ipfs name publish /ipfs/bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244
184193

185-
> Published to k51qzi5uqu5dkkciu33khkzbcmxtyhn376i1e83tya8kuy7z9euedzyr5nhoew: /ipfs/QmUVTKsrYJpaxUT7dr9FpKq6AoKHhEM7eG1ZHGL56haKLG
194+
> Published to k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l: /ipfs/bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244
186195
```
187196

188197
`k51...` is the public key or IPNS name of the IPFS you are running. You can now change the file repeatedly, and, even though the CID changes when you change the file, you can continue to access it with this key.
189198

190-
1. You can view your file by going to `https://gateway.ipfs.io/ipns/k51qzi5uqu5dkkciu33khkzbcmxtyhn376i1e83tya8kuy7z9euedzyr5nhoew`:
199+
1. You can view your file by going to `https://ipfs.io/ipns/k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l`:
191200

192201
```shell
193-
curl https://gateway.ipfs.io/ipns/k51qzi5uqu5dkkciu33khkzbcmxtyhn376i1e83tya8kuy7z9euedzyr5nhoew
202+
curl https://ipfs.io/ipns/k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l
194203

195204
> Hello IPFS
196205
```
@@ -201,18 +210,18 @@ When looking up an IPNS address, use the `/ipns/` prefix:
201210
echo "Hello again IPFS" > hello.txt
202211
ipfs add hello.txt
203212

204-
> added QmaVfeg2GM17RLjBs9C4fhpku6uDgrEGUYCTC183VrZaVW hello.txt
213+
> added bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq hello.txt
205214
> 17 B / 17 B [=====================================================] 100.00%
206215

207-
ipfs name publish QmaVfeg2GM17RLjBs9C4fhpku6uDgrEGUYCTC183VrZaVW
216+
ipfs name publish bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq
208217

209-
> Published to k51qzi5uqu5dkkciu33khkzbcmxtyhn376i1e83tya8kuy7z9euedzyr5nhoew: /ipfs/QmaVfeg2GM17RLjBs9C4fhpku6uDgrEGUYCTC183VrZaVW
218+
> Published to k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l: /ipfs/bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq
210219
```
211220

212-
1. You can now go back to `https://gateway.ipfs.io/ipns/k51qzi5uqu5dkkciu33khkzbcmxtyhn376i1e83tya8kuy7z9euedzyr5nhoew` to view your updated file using the same address:
221+
2. You can now go back to `https://ipfs.io/ipns/k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l` to view your updated file using the same address:
213222

214223
```shell
215-
curl https://gateway.ipfs.io/ipns/k51qzi5uqu5dkkciu33khkzbcmxtyhn376i1e83tya8kuy7z9euedzyr5nhoew
224+
curl https://ipfs.io/ipns/k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l
216225

217226
> Hello again IPFS
218227
```
@@ -222,7 +231,7 @@ You can view the CID of the file associated with your `k5` key by using `name re
222231
```shell
223232
ipfs name resolve
224233

225-
> /ipfs/QmaVfeg2GM17RLjBs9C4fhpku6uDgrEGUYCTC183VrZaVW
234+
> /ipfs/bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq
226235
```
227236

228237
To use a different `k5` key, first create one using `key gen test`, and use the `--key` flag when calling `name publish`:
@@ -232,9 +241,9 @@ ipfs key gen SecondKey
232241

233242
> k51qzi5uqu5dh5kbbff1ucw3ksphpy3vxx4en4dbtfh90pvw4mzd8nfm5r5fnl
234243

235-
ipfs name publish --key=SecondKey /ipfs/QmaVfeg2GM17RLjBs9C4fhpku6uDgrEGUYCTC183VrZaVW
244+
ipfs name publish --key=SecondKey /ipfs/bafybeicklkqcnlvtiscr2hzkubjwnwjinvskffn4xorqeduft3wq7vm5u4
236245

237-
> Published to k51qzi5uqu5dh5kbbff1ucw3ksphpy3vxx4en4dbtfh90pvw4mzd8nfm5r5fnl: /ipfs/QmaVfeg2GM17RLjBs9C4fhpku6uDgrEGUYCTC183VrZaVW
246+
> Published to k51qzi5uqu5dh5kbbff1ucw3ksphpy3vxx4en4dbtfh90pvw4mzd8nfm5r5fnl: /ipfs/bafybeicklkqcnlvtiscr2hzkubjwnwjinvskffn4xorqeduft3wq7vm5u4
238247
```
239248

240249
## Example IPNS Setup with JS SDK API
@@ -245,13 +254,13 @@ Here's where the Name API comes in handy. With it, you can create a single, stab
245254

246255
```javascript
247256
// The address of your files.
248-
const addr = '/ipfs/QmbezGequPwcsWo8UL4wDF6a8hYwM1hmbzYv2mnKkEWaUp'
257+
const addr = '/ipfs/bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq'
249258

250259
ipfs.name.publish(addr).then(function (res) {
251260
// You now receive a res which contains two fields:
252261
// - name: the name under which the content was published.
253262
// - value: the "real" address to which Name points.
254-
console.log(`https://gateway.ipfs.io/ipns/${res.name}`)
263+
console.log(`https://ipfs.io/ipns/${res.name}`)
255264
})
256265
```
257266

0 commit comments

Comments
 (0)