Skip to content

Commit

Permalink
chore: migration: Use autobatch bs (#5396)
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Oct 21, 2022
1 parent 638b80d commit db63d95
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions pkg/fork/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -2204,11 +2204,11 @@ func (c *ChainFork) upgradeActorsV9Common(ctx context.Context,
ts *types.TipSet,
config nv17.Config,
) (cid.Cid, error) {
buf := blockstoreutil.NewTieredBstore(c.bs, blockstoreutil.NewTemporarySync())
store := chain.ActorStore(ctx, buf)
writeStore := blockstoreutil.NewAutobatch(ctx, c.bs, units.GiB/4)
store := chain.ActorStore(ctx, writeStore)

// ensure that the manifest is loaded in the blockstore
if err := actors.LoadBundles(ctx, buf, actorstypes.Version9); err != nil {
if err := actors.LoadBundles(ctx, c.bs, actorstypes.Version9); err != nil {
return cid.Undef, fmt.Errorf("failed to load manifest bundle: %w", err)
}

Expand Down Expand Up @@ -2244,15 +2244,13 @@ func (c *ChainFork) upgradeActorsV9Common(ctx context.Context,
return cid.Undef, fmt.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, fmt.Errorf("writeStore flush failed: %w", err)
}

if err := Copy(ctx, from, to, newRoot); err != nil {
return cid.Undef, fmt.Errorf("copying migrated tree: %w", err)
}
if err := writeStore.Shutdown(ctx); err != nil {
return cid.Undef, fmt.Errorf("writeStore shutdown failed: %w", err)
}

return newRoot, nil
Expand Down

0 comments on commit db63d95

Please sign in to comment.