diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index 8efe532f4..6306cd18c 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -67,6 +67,11 @@ var importBenchCmd = &cli.Command{ return err } bs := blockstore.NewBlockstore(bds) + cbs, err := blockstore.CachedBlockstore(context.TODO(), bs, blockstore.DefaultCacheOpts()) + if err != nil { + return err + } + bs = cbs ds := datastore.NewMapDatastore() cs := store.NewChainStore(bs, ds, vm.Syscalls(ffiwrapper.ProofVerifier)) stm := stmgr.NewStateManager(cs) diff --git a/node/modules/chain.go b/node/modules/chain.go index 678cca723..ca0281acf 100644 --- a/node/modules/chain.go +++ b/node/modules/chain.go @@ -60,14 +60,19 @@ func MessagePool(lc fx.Lifecycle, sm *stmgr.StateManager, ps *pubsub.PubSub, ds return mp, nil } -func ChainBlockstore(r repo.LockedRepo) (dtypes.ChainBlockstore, error) { +func ChainBlockstore(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.LockedRepo) (dtypes.ChainBlockstore, error) { blocks, err := r.Datastore("/blocks") if err != nil { return nil, err } bs := blockstore.NewBlockstore(blocks) - return blockstore.NewIdStore(bs), nil + cbs, err := blockstore.CachedBlockstore(helpers.LifecycleCtx(mctx, lc), bs, blockstore.DefaultCacheOpts()) + if err != nil { + return nil, err + } + + return blockstore.NewIdStore(cbs), nil } func ChainGCBlockstore(bs dtypes.ChainBlockstore, gcl dtypes.ChainGCLocker) dtypes.ChainGCBlockstore {