From 9db17fbe3d1744cb0d3e45a8b93759dba6cef26f Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 4 Apr 2024 20:00:46 +0200 Subject: [PATCH] feat(config): Reprovider.Strategy=flat Adding 'flat' strategy which works the same as the old default 'all'. This way if anyone has memory-related regressions, they can fix without waiting for a new release. --- core/node/provider.go | 2 ++ docs/changelogs/v0.28.md | 2 +- docs/config.md | 3 +++ test/cli/provider_test.go | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/core/node/provider.go b/core/node/provider.go index 40d61038df7..c28989afb53 100644 --- a/core/node/provider.go +++ b/core/node/provider.go @@ -134,6 +134,8 @@ func OnlineProviders(useStrategicProviding bool, reprovideStrategy string, repro keyProvider = fx.Provide(newProvidingStrategy(true, true)) case "pinned": keyProvider = fx.Provide(newProvidingStrategy(true, false)) + case "flat": + keyProvider = fx.Provide(provider.NewBlockstoreProvider) default: return fx.Error(fmt.Errorf("unknown reprovider strategy %q", reprovideStrategy)) } diff --git a/docs/changelogs/v0.28.md b/docs/changelogs/v0.28.md index afcd136ec39..1948509cf3f 100644 --- a/docs/changelogs/v0.28.md +++ b/docs/changelogs/v0.28.md @@ -38,7 +38,7 @@ To support testing scenarios where multiple Kubo instances run on the same machi #### Pin roots are now prioritized when announcing -The pin roots are now prioritized when announcing content in the Amino DHT, making the content accessible faster. +The root CIDs of pinned content are now prioritized when announcing to the Amino DHT with [`Reprovider.Strategy`](https://github.com/ipfs/kubo/blob/master/docs/config.md#reproviderstrategy) set to `all` (default) or `pinned`, making the important CIDs accessible faster. ### 📝 Changelog diff --git a/docs/config.md b/docs/config.md index ad308b18c5b..0bcffe3e7b0 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1501,7 +1501,9 @@ Type: `optionalDuration` (unset for the default) Tells reprovider what should be announced. Valid strategies are: - `"all"` - announce all CIDs of stored blocks + - Order: root blocks of direct and recursive pins are announced first, then the rest of blockstore - `"pinned"` - only announce pinned CIDs recursively (both roots and child blocks) + - Order: root blocks of direct and recursive pins are announced first, then the child blocks of recursive pins - `"roots"` - only announce the root block of explicitly pinned CIDs - **⚠️ BE CAREFUL:** node with `roots` strategy will not announce child blocks. It makes sense only for use cases where the entire DAG is fetched in full, @@ -1510,6 +1512,7 @@ Tells reprovider what should be announced. Valid strategies are: providers for the missing block in the middle of a file, unless the peer happens to already be connected to a provider and ask for child CID over bitswap. +- `"flat"` - same as `all`, announce all CIDs of stored blocks, but without prioritizing anything Default: `"all"` diff --git a/test/cli/provider_test.go b/test/cli/provider_test.go index b2d98e8822e..5ecf8f3cab7 100644 --- a/test/cli/provider_test.go +++ b/test/cli/provider_test.go @@ -74,6 +74,23 @@ func TestProvider(t *testing.T) { expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...) }) + t.Run("Reprovides with 'flat' strategy", func(t *testing.T) { + t.Parallel() + + nodes := initNodes(t, 2, func(n *harness.Node) { + n.SetIPFSConfig("Reprovider.Strategy", "flat") + }) + defer nodes.StopDaemons() + + cid := nodes[0].IPFSAddStr(time.Now().String(), "--local") + + expectNoProviders(t, cid, nodes[1:]...) + + nodes[0].IPFS("bitswap", "reprovide") + + expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...) + }) + t.Run("Reprovides with 'pinned' strategy", func(t *testing.T) { t.Parallel()