brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.54k stars 2.27k forks source link

IPFS: IPNS republishing is flaky due to lazy-loaded daemon #27761

Open lidel opened 1 year ago

lidel commented 1 year ago

Description

I suspect the problem is the lazy-loaded nature of IPFS implementation in Brave.

In sumple terms, DHT expires records after 24h (we are in the process of raising that to 48h). This means IPNS record needs to be republished at least once a day.

Potential problem: Brave starts IPFS node on-demand, when ipfs:// URI is requested.

If you closed your browser, and opened it again but never interacted with IPFS, you will have no daemon running until you trigger it's launch, eg. by opening ipfs:// or ipns:// again.

This means your IPNS record will expire because your IPNS node is not running to re-announce it.

Steps to Reproduce

  1. Publish something to IPNS
  2. Close Brave
  3. Start Brave
  4. Wait a day without using IPFS
  5. Try to resolve IPNS address

Actual result:

IPNS does not resolve, no valid record is found.

Expected result:

Published IPNS resolves.

Reproduces how often:

Every time.

Desktop Brave version:

v1.46.153 (Jan 6, 2023)

Potential ways to fix

The only proper fix is to run IPFS node.

If Brave wants to keep lazy-loaded default, I propose we detect when IPFS node has published to IPNS, or pinned some data, and in such case ALWAYS run it.

This check could be run asynchronously when Brave starts and user previouslu enabled local node.

How to detect IPNS was used for publishing

You can detect when IPNS was used by enumerating local keys (ipfs key list -l and trying to resolve each locally, without asking other peers (ipfs name resolve k....keyhash --offline). All should error.

If any of the keys resolves over IPNS to /ipfs/.. then we need to always run the node.

How to detect when user pinned any data

cc @cypt4 @unicomp21 @autonome

unicomp21 commented 1 year ago

ipfs pin ls --type=recursive

Where does brave install ipfs command line on my mac? @lidel