From cb74f8cde0a346295e5b47c42672e5650a815149 Mon Sep 17 00:00:00 2001 From: SatoshiQaziMuhammed Date: Fri, 6 Nov 2026 13:14:06 +0400 Subject: [PATCH] Fetch .kurd content from our own gateway first, and believe a proven absence (#39) ipfs.io and dweb.link now send trustless (?format=car) requests on to trustless-gateway.link, which only finds content announced over HTTP: for the dks.news package our node pins and serves it answered 525/526. The built-in list now starts with ipfs.pezkuwichain.io, a trustless-only gateway serving just what our node pins; the public two stay as fallbacks. Every block is still checked against the root, so the order changes reachability, not trust. A trustless gateway answers a path that is not there with 200 and the directory blocks that lack it. The fetcher took that for "no answer" and the reader saw Unavailable for a plain 404. A missing block throws in the reader, so a null from a verified CAR means the name is absent: it is now NotFound in one request. --- .../runtime/names/content/KurdContentFetcher.kt | 13 ++++++++++--- .../runtime/names/content/KurdContentFetcherTest.kt | 10 ++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/names/content/KurdContentFetcher.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/names/content/KurdContentFetcher.kt index 49627856..18f19ffb 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/names/content/KurdContentFetcher.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/names/content/KurdContentFetcher.kt @@ -54,8 +54,13 @@ class RealKurdGateways( const val LIST_URL = "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/master/kurd/gateways.json" - /** Measured reachable from Türkiye (architecture, M0); our own mirrors join through the signed list. */ - val BUILT_IN = listOf("https://ipfs.io", "https://dweb.link") + /** + * Ours first: since 2026 ipfs.io and dweb.link send `?format=car` on to trustless-gateway.link, + * which finds only content announced over HTTP (measured 2026-11-06: 525/526 for a site our + * node pins and serves). The two stay as fallbacks; both were measured reachable from Türkiye + * (architecture, M0). More mirrors join through the signed list. + */ + val BUILT_IN = listOf("https://ipfs.pezkuwichain.io", "https://ipfs.io", "https://dweb.link") private const val TAG = "KurdGateways" @@ -130,7 +135,9 @@ class KurdContentFetcher( private suspend fun read(gateway: String, root: Cid, path: List): Lookup? { val car = source.car(gateway, root, path) if (car != null) { - val entry = UnixFsReader(VerifiedBlocks.fromCar(car), maxFileSize).read(root, path) ?: return null + // A missing block throws; null means the verified directories on the way lack the name, + // which is how a trustless gateway answers for a path that is not there + val entry = UnixFsReader(VerifiedBlocks.fromCar(car), maxFileSize).read(root, path) ?: return Lookup.Absent return Lookup.Found(entry) } diff --git a/runtime/src/test/java/io/novafoundation/nova/runtime/names/content/KurdContentFetcherTest.kt b/runtime/src/test/java/io/novafoundation/nova/runtime/names/content/KurdContentFetcherTest.kt index 8918b493..1eac34c9 100644 --- a/runtime/src/test/java/io/novafoundation/nova/runtime/names/content/KurdContentFetcherTest.kt +++ b/runtime/src/test/java/io/novafoundation/nova/runtime/names/content/KurdContentFetcherTest.kt @@ -38,6 +38,16 @@ class KurdContentFetcherTest { assertSame(KurdContentFetcher.Result.NotFound, KurdContentFetcher(gateways("https://one"), honest).fetch(root, listOf("subdir", "missing.txt"))) } + @Test + fun `a gateway proving the name absent in one answer is believed`() = runBlocking { + // Kubo's trustless gateway answers a missing path with the directory blocks that lack it + val asked = mutableListOf>() + val source = CarSource { _, _, path -> asked += path; car } + + assertSame(KurdContentFetcher.Result.NotFound, KurdContentFetcher(gateways("https://one"), source).fetch(root, listOf("subdir", "missing.txt"))) + assertEquals(listOf(listOf("subdir", "missing.txt")), asked) + } + @Test fun `a directory is served through its index and without one is not found`() = runBlocking { val source = CarSource { _, _, path -> if (path.lastOrNull() == KurdContentFetcher.INDEX) null else car }