Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions cmd/ipfs/kubo/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,11 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
if cfg.Provider.Strategy.WithDefault("") != "" && cfg.Reprovider.Strategy.IsDefault() {
log.Fatal("Invalid config. Remove unused Provider.Strategy and set Reprovider.Strategy instead. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#reproviderstrategy")
}
if cfg.Experimental.StrategicProviding {
log.Error("Experimental.StrategicProviding was removed. Remove it from your config and set Provider.Enabled=false to remove this message. Documentation: https://github.com/ipfs/kubo/blob/master/docs/experimental-features.md#strategic-providing")
cfg.Experimental.StrategicProviding = false
cfg.Provider.Enabled = config.False
}

printLibp2pPorts(node)

Expand Down Expand Up @@ -625,17 +630,19 @@ take effect.
}()

if !offline {
// Warn users who were victims of 'lowprofile' footgun (https://github.com/ipfs/kubo/pull/10524)
if cfg.Experimental.StrategicProviding {
// Warn users when provide systems are disabled
if !cfg.Provider.Enabled.WithDefault(config.DefaultProviderEnabled) {
fmt.Print(`
⚠️ Reprovide system is disabled due to 'Experimental.StrategicProviding=true'

⚠️ Provide and Reprovide systems are disabled due to 'Provide.Enabled=false'
⚠️ Local CIDs will not be announced to Amino DHT, making them impossible to retrieve without manual peering
⚠️ If this is not intentional, call 'ipfs config profile apply announce-on'
⚠️ If this is not intentional, call 'ipfs config profile apply announce-on' or set Provide.Enabled=true'

`)
} else if cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval) == 0 {
fmt.Print(`
⚠️ Reprovider system is disabled due to 'Reprovider.Interval=0'

⚠️ Provide and Reprovide systems are disabled due to 'Reprovider.Interval=0'
⚠️ Local CIDs will not be announced to Amino DHT, making them impossible to retrieve without manual peering
⚠️ If this is not intentional, call 'ipfs config profile apply announce-on', or set 'Reprovider.Interval=22h'

Expand Down
2 changes: 1 addition & 1 deletion config/experiments.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Experiments struct {
ShardingEnabled bool `json:",omitempty"` // deprecated by autosharding: https://github.com/ipfs/kubo/pull/8527
Libp2pStreamMounting bool
P2pHttpProxy bool //nolint
StrategicProviding bool
StrategicProviding bool `json:",omitempty"` // removed, use Provider.Enabled instead
OptimisticProvide bool
OptimisticProvideJobsPoolSize int
GatewayOverLibp2p bool `json:",omitempty"`
Expand Down
8 changes: 4 additions & 4 deletions config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fetching may be degraded.
},
},
"announce-off": {
Description: `Disables Reprovide system (and announcing to Amino DHT).
Description: `Disables Provide and Reprovide systems (announcing to Amino DHT).

USE WITH CAUTION:
The main use case for this is setups with manual Peering.Peers config.
Expand All @@ -279,16 +279,16 @@ fetching may be degraded.
one hosting it, and other peers are not already connected to it.
`,
Transform: func(c *Config) error {
c.Provider.Enabled = False
c.Reprovider.Interval = NewOptionalDuration(0) // 0 disables periodic reprovide
c.Experimental.StrategicProviding = true // this is not a typo (the name is counter-intuitive)
return nil
},
},
"announce-on": {
Description: `Re-enables Reprovide system (reverts announce-off profile).`,
Description: `Re-enables Provide and Reprovide systems (reverts announce-off profile).`,
Transform: func(c *Config) error {
c.Provider.Enabled = True
c.Reprovider.Interval = NewOptionalDuration(DefaultReproviderInterval) // have to apply explicit default because nil would be ignored
c.Experimental.StrategicProviding = false // this is not a typo (the name is counter-intuitive)
return nil
},
},
Expand Down
4 changes: 3 additions & 1 deletion config/provider.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package config

const (
DefaultProviderWorkerCount = 64
DefaultProviderEnabled = true
DefaultProviderWorkerCount = 16
)

// Provider configuration describes how NEW CIDs are announced the moment they are created.
// For periodical reprovide configuration, see Reprovider.*
type Provider struct {
Enabled Flag `json:",omitempty"`
Strategy *OptionalString `json:",omitempty"` // Unused, you are likely looking for Reprovider.Strategy instead
WorkerCount *OptionalInteger `json:",omitempty"` // Number of concurrent provides allowed, 0 means unlimited
}
3 changes: 2 additions & 1 deletion config/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ type Routing struct {

IgnoreProviders []string `json:",omitempty"`

// Simplified configuration used by default when Routing.Type=auto|autoclient
DelegatedRouters []string `json:",omitempty"`

// Advanced configuration used when Routing.Type=custom
Routers Routers `json:",omitempty"`

Methods Methods `json:",omitempty"`
}

Expand Down
21 changes: 21 additions & 0 deletions core/commands/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

"github.com/ipfs/kubo/config"
cmdenv "github.com/ipfs/kubo/core/commands/cmdenv"

dag "github.com/ipfs/boxo/ipld/merkledag"
Expand Down Expand Up @@ -158,6 +159,14 @@ var provideRefRoutingCmd = &cmds.Command{
if !nd.IsOnline {
return ErrNotOnline
}
// respect global config
cfg, err := nd.Repo.Config()
if err != nil {
return err
}
if !cfg.Provider.Enabled.WithDefault(config.DefaultProviderEnabled) {
return errors.New("invalid configuration: Provider.Enabled is set to 'false'")
}

if len(nd.PeerHost.Network().Conns()) == 0 {
return errors.New("cannot provide, no connected peers")
Expand Down Expand Up @@ -254,6 +263,18 @@ Trigger reprovider to announce our data to network.
return ErrNotOnline
}

// respect global config
cfg, err := nd.Repo.Config()
if err != nil {
return err
}
if !cfg.Provider.Enabled.WithDefault(config.DefaultProviderEnabled) {
return errors.New("invalid configuration: Provider.Enabled is set to 'false'")
}
if cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval) == 0 {
return errors.New("invalid configuration: Reprovider.Interval is set to '0'")
}

err = nd.Provider.Reprovide(req.Context)
if err != nil {
return err
Expand Down
7 changes: 4 additions & 3 deletions core/node/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type bitswapIn struct {
// Bitswap creates the BitSwap server/client instance.
// If Bitswap.ServerEnabled is false, the node will act only as a client
// using an empty blockstore to prevent serving blocks to other peers.
func Bitswap(serverEnabled bool) interface{} {
func Bitswap(serverEnabled, libp2pEnabled, httpEnabled bool) interface{} {
return func(in bitswapIn, lc fx.Lifecycle) (*bitswap.Bitswap, error) {
var bitswapNetworks, bitswapLibp2p network.BitSwapNetwork
var bitswapBlockstore blockstore.Blockstore = in.Bs
Expand All @@ -93,7 +93,8 @@ func Bitswap(serverEnabled bool) interface{} {
bitswapLibp2p = bsnet.NewFromIpfsHost(in.Host)
}

if httpCfg := in.Cfg.HTTPRetrieval; httpCfg.Enabled.WithDefault(config.DefaultHTTPRetrievalEnabled) {
if httpEnabled {
httpCfg := in.Cfg.HTTPRetrieval
maxBlockSize, err := humanize.ParseBytes(httpCfg.MaxBlockSize.WithDefault(config.DefaultHTTPRetrievalMaxBlockSize))
if err != nil {
return nil, err
Expand Down Expand Up @@ -136,7 +137,7 @@ func Bitswap(serverEnabled bool) interface{} {
return nil, err
}

// Explicitly enable/disable server to ensure desired provide mode
// Explicitly enable/disable server
in.BitswapOpts = append(in.BitswapOpts, bitswap.WithServerEnabled(serverEnabled))

bs := bitswap.New(helpers.LifecycleCtx(in.Mctx, lc), bitswapNetworks, providerQueryMgr, bitswapBlockstore, in.BitswapOpts...)
Expand Down
12 changes: 7 additions & 5 deletions core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,18 @@ func Online(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part

isBitswapLibp2pEnabled := cfg.Bitswap.Libp2pEnabled.WithDefault(config.DefaultBitswapLibp2pEnabled)
isBitswapServerEnabled := cfg.Bitswap.ServerEnabled.WithDefault(config.DefaultBitswapServerEnabled)
isHTTPRetrievalEnabled := cfg.HTTPRetrieval.Enabled.WithDefault(config.DefaultHTTPRetrievalEnabled)

// Don't provide from bitswap when the legacy noop experiment "strategic provider service" is active
isBitswapServerEnabled = isBitswapServerEnabled && !cfg.Experimental.StrategicProviding
// Right now Provider and Reprovider systems are tied together - disabling Reprovider by setting interval to 0 disables Provider
// and vice versa: Provider.Enabled=false will disable both Provider of new CIDs and the Reprovider of old ones.
isProviderEnabled := cfg.Provider.Enabled.WithDefault(config.DefaultProviderEnabled) && cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval) != 0

return fx.Options(
fx.Provide(BitswapOptions(cfg)),
fx.Provide(Bitswap(isBitswapServerEnabled)),
fx.Provide(Bitswap(isBitswapServerEnabled, isBitswapLibp2pEnabled, isHTTPRetrievalEnabled)),
fx.Provide(OnlineExchange(isBitswapLibp2pEnabled)),
// Replace our Exchange with a Providing exchange!
fx.Decorate(ProvidingExchange(isBitswapServerEnabled)),
fx.Decorate(ProvidingExchange(isProviderEnabled && isBitswapServerEnabled)),
fx.Provide(DNSResolver),
fx.Provide(Namesys(ipnsCacheSize, cfg.Ipns.MaxCacheTTL.WithDefault(config.DefaultIpnsMaxCacheTTL))),
fx.Provide(Peering),
Expand All @@ -358,7 +360,7 @@ func Online(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part

LibP2P(bcfg, cfg, userResourceOverrides),
OnlineProviders(
cfg.Experimental.StrategicProviding,
isProviderEnabled,
cfg.Reprovider.Strategy.WithDefault(config.DefaultReproviderStrategy),
cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval),
cfg.Routing.AcceleratedDHTClient.WithDefault(config.DefaultAcceleratedDHTClient),
Expand Down
4 changes: 2 additions & 2 deletions core/node/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ https://github.com/ipfs/kubo/blob/master/docs/config.md#routingaccelerateddhtcli
// ONLINE/OFFLINE

// OnlineProviders groups units managing provider routing records online
func OnlineProviders(useStrategicProviding bool, reprovideStrategy string, reprovideInterval time.Duration, acceleratedDHTClient bool, provideWorkerCount int) fx.Option {
if useStrategicProviding {
func OnlineProviders(provide bool, reprovideStrategy string, reprovideInterval time.Duration, acceleratedDHTClient bool, provideWorkerCount int) fx.Option {
if !provide {
return OfflineProviders()
}

Expand Down
12 changes: 8 additions & 4 deletions docs/changelogs/v0.35.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ to delays in initial advertisements (provides).
Provides and Reprovides now have separate queues, allowing for immediate
provide of new CIDs and optimised batching of reprovides.

This change introduces a new configuration option for limiting the number of
concurrent provide operations:
[`Provider.WorkerCount`](https://github.com/ipfs/kubo/blob/master/docs/config.md#providerworkercount).
###### New `Provider` configuration options

This change introduces a new configuration options:

- [`Provider.Enabled`](https://github.com/ipfs/kubo/blob/master/docs/config.md#providerenabled) is a global flag for disabling both [Provider](https://github.com/ipfs/kubo/blob/master/docs/config.md#provider) and [Reprovider](https://github.com/ipfs/kubo/blob/master/docs/config.md#reprovider) systems (announcing new/old CIDs to amino DHT).
- [`Provider.WorkerCount`](https://github.com/ipfs/kubo/blob/master/docs/config.md#providerworkercount) for limiting the number of concurrent provide operations, allows for fine-tuning the trade-off between announcement speed and system load when announcing new CIDs.
- Removed `Experimental.StrategicProviding`. Superseded by `Provider.Enabled`, `Reprovider.Interval` and [`Reprovider.Strategy`](https://github.com/ipfs/kubo/blob/master/docs/config.md#reproviderstrategy).

> [!TIP]
> Users who need to provide large volumes of content immediately should consider removing the cap on concurrent provide operations and also set `Routing.AcceleratedDHTClient` to `true`.
> Users who need to provide large volumes of content immediately should consider setting `Routing.AcceleratedDHTClient` to `true`. If that is not enough, consider adjusting `Provider.WorkerCount` to a higher value.

###### Deprecated `ipfs stats provider`

Expand Down
Loading
Loading