From 2a669d869bd27186dcc2cd6f05be68942f4d2325 Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Fri, 19 Sep 2025 19:59:46 +0200 Subject: [PATCH] fix: SweepingProvider shouldn't error when missing DHT (#10975) * fix: SweepingProvider shouldn't error when missing DHT * fix: prevent panic when SweepingProvider has no DHT when SweepingProvider is enabled but no DHT is available (e.g., Routing.Type=none), the daemon would panic with a nil pointer dereference in ResettableKeystore.ResetCids. this fix: - returns NoopProvider when no DHT implementation is available - skips keystore initialization for NoopProvider to avoid unnecessary operations - allows nodes to run without DHT when using HTTP-only routing or offline mode the panic occurred because initKeyStore tried to access a nil keystore when SweepingProvider returned nil for the keystore parameter. by checking if the provider is NoopProvider and skipping keystore operations, we avoid the panic while maintaining correct behavior for all other provider types. cc #10974 #10975 --------- Co-authored-by: Marcin Rataj --- core/node/provider.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/node/provider.go b/core/node/provider.go index 3aff6e53c..80d026f44 100644 --- a/core/node/provider.go +++ b/core/node/provider.go @@ -355,13 +355,7 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option { } } if impl == nil { - // No DHT available, check if HTTP provider is configured - cfg, err := in.Repo.Config() - if err == nil && cfg.HasHTTPProviderConfigured() { - // HTTP provider is configured, return NoopProvider to allow HTTP-based providing - return &NoopProvider{}, keyStore, nil - } - return &NoopProvider{}, nil, errors.New("provider: no valid DHT available for providing") + return &NoopProvider{}, nil, nil } var selfAddrsFunc func() []ma.Multiaddr @@ -403,6 +397,11 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option { KeyProvider provider.KeyChanFunc } initKeyStore := fx.Invoke(func(lc fx.Lifecycle, in keystoreInput) { + // Skip keystore initialization for NoopProvider + if _, ok := in.Provider.(*NoopProvider); ok { + return + } + var ( cancel context.CancelFunc done = make(chan struct{})