Skip to content

Commit 1e9b6fb

Browse files
fix: SweepingProvider slow start (#10980)
* fix: SweepingProvider slow start #10979 * don't purge keystore * feat: add INFO logging for provider keystore sync log start/completion of async keystore sync with strategy --------- Co-authored-by: Marcin Rataj <[email protected]>
1 parent 46d438f commit 1e9b6fb

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

core/node/provider.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,18 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
428428
// replace them with the keys that needs to be reprovided, coming from
429429
// the KeyChanFunc. So far, this is the less worse way to remove CIDs
430430
// that shouldn't be reprovided from the provider's state.
431-
if err := syncKeyStore(ctx); err != nil {
432-
return err
433-
}
431+
go func() {
432+
// Sync the keystore once at startup. This operation is async since
433+
// we need to walk the DAG of objects matching the provide strategy,
434+
// which can take a while.
435+
strategy := cfg.Provide.Strategy.WithDefault(config.DefaultProvideStrategy)
436+
logger.Infow("provider keystore sync started", "strategy", strategy)
437+
if err := syncKeyStore(ctx); err != nil {
438+
logger.Errorw("provider keystore sync failed", "err", err, "strategy", strategy)
439+
} else {
440+
logger.Infow("provider keystore sync completed", "strategy", strategy)
441+
}
442+
}()
434443

435444
gcCtx, c := context.WithCancel(context.Background())
436445
cancel = c
@@ -462,10 +471,10 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
462471
case <-ctx.Done():
463472
return ctx.Err()
464473
}
465-
// KeyStore state isn't be persisted across restarts.
466-
if err := in.KeyStore.Empty(ctx); err != nil {
467-
return err
468-
}
474+
475+
// Keystore data isn't purged, on close, but it will be overwritten
476+
// when the node starts again.
477+
469478
return in.KeyStore.Close()
470479
},
471480
})

0 commit comments

Comments
 (0)