Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migration: Use autobatch bs #5396

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion pkg/util/blockstoreutil/autobatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down