From 66bb149a65949b3bacbcf75e1fd367e4fbd6a47b Mon Sep 17 00:00:00 2001 From: Aayush Date: Wed, 19 Oct 2022 11:47:33 -0400 Subject: [PATCH 1/2] Migration: Use autobatch bs --- chain/consensus/filcns/upgrades.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index c7044c9b5f2..07184ec6857 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -1492,11 +1492,11 @@ func upgradeActorsV9Common( root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet, config nv17.Config, ) (cid.Cid, error) { - buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync()) - store := store.ActorStore(ctx, buf) + writeStore := blockstore.NewAutobatch(ctx, sm.ChainStore().StateBlockstore(), units.GiB/4) + store := store.ActorStore(ctx, writeStore) // ensure that the manifest is loaded in the blockstore - if err := bundle.LoadBundles(ctx, buf, actorstypes.Version9); err != nil { + if err := bundle.LoadBundles(ctx, sm.ChainStore().StateBlockstore(), actorstypes.Version9); err != nil { return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err) } @@ -1535,15 +1535,13 @@ func upgradeActorsV9Common( return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err) } - // Persist the new tree. - - { - from := buf - to := buf.Read() + // Persists the new tree and shuts down the flush worker + if err := writeStore.Flush(ctx); err != nil { + return cid.Undef, xerrors.Errorf("writeStore flush failed: %w", err) + } - if err := vm.Copy(ctx, from, to, newRoot); err != nil { - return cid.Undef, xerrors.Errorf("copying migrated tree: %w", err) - } + if err := writeStore.Shutdown(ctx); err != nil { + return cid.Undef, xerrors.Errorf("writeStore shutdown failed: %w", err) } return newRoot, nil From 66f8af9b0c2e5eccb8c1053d8c5dcab64360fd16 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 19 Oct 2022 17:56:52 +0200 Subject: [PATCH 2/2] Fix autobatch Signed-off-by: Jakub Sztandera --- blockstore/autobatch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockstore/autobatch.go b/blockstore/autobatch.go index 90f4ad071e1..d810212d23b 100644 --- a/blockstore/autobatch.go +++ b/blockstore/autobatch.go @@ -192,7 +192,7 @@ func (bs *AutobatchBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block, return v, nil } - return bs.Get(ctx, c) + return nil, ipld.ErrNotFound{Cid: c} } func (bs *AutobatchBlockstore) DeleteBlock(context.Context, cid.Cid) error {