Skip to content

Commit 3f712c3

Browse files
committed
Example V9 migration function
1 parent bec1dc4 commit 3f712c3

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

chain/consensus/filcns/upgrades.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,10 +1431,29 @@ func upgradeActorsV8Common(
14311431
return newRoot, nil
14321432
}
14331433

1434-
func UpgradeActorsCode(ctx context.Context, sm *stmgr.StateManager, newActorsManifestCid cid.Cid, root cid.Cid, av actors.Version, oldStateTreeVersion types.StateTreeVersion, newStateTreeVersion types.StateTreeVersion) (cid.Cid, error) {
1435-
bstore := sm.ChainStore().StateBlockstore()
1436-
return LiteMigration(ctx, bstore, newActorsManifestCid, root, av, oldStateTreeVersion, newStateTreeVersion)
1437-
}
1434+
// Example upgrade function if upgrade requires only code changes
1435+
//func UpgradeActorsV9(ctx context.Context, sm *stmgr.StateManager, _ stmgr.MigrationCache, _ stmgr.ExecMonitor, root cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) (cid.Cid, error) {
1436+
// buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync())
1437+
//
1438+
// av := actors.Version9
1439+
// // This may change for upgrade
1440+
// newStateTreeVersion := types.StateTreeVersion4
1441+
//
1442+
// // ensure that the manifest is loaded in the blockstore
1443+
// if err := bundle.FetchAndLoadBundles(ctx, buf, map[actors.Version]build.Bundle{
1444+
// av: build.BuiltinActorReleases[av],
1445+
// }); err != nil {
1446+
// return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err)
1447+
// }
1448+
//
1449+
// newActorsManifestCid, ok := actors.GetManifest(av)
1450+
// if !ok {
1451+
// return cid.Undef, xerrors.Errorf("no manifest CID for v8 upgrade")
1452+
// }
1453+
//
1454+
// bstore := sm.ChainStore().StateBlockstore()
1455+
// return LiteMigration(ctx, bstore, newActorsManifestCid, root, av, types.StateTreeVersion4, newStateTreeVersion)
1456+
//}
14381457

14391458
func LiteMigration(ctx context.Context, bstore blockstore.Blockstore, newActorsManifestCid cid.Cid, root cid.Cid, av actors.Version, oldStateTreeVersion types.StateTreeVersion, newStateTreeVersion types.StateTreeVersion) (cid.Cid, error) {
14401459
buf := blockstore.NewTieredBstore(bstore, blockstore.NewMemorySync())
@@ -1479,12 +1498,12 @@ func LiteMigration(ctx context.Context, bstore blockstore.Blockstore, newActorsM
14791498
return cid.Undef, xerrors.Errorf("error loading new manifest data: %w", err)
14801499
}
14811500

1482-
if len(newManifestData.Entries) != len(actors.GetBuiltinActorsKeys()) {
1483-
return cid.Undef, xerrors.Errorf("incomplete new manifest with %d code CIDs", len(newManifestData.Entries))
1484-
}
14851501
if len(oldManifestData.Entries) != len(actors.GetBuiltinActorsKeys()) {
14861502
return cid.Undef, xerrors.Errorf("incomplete old manifest with %d code CIDs", len(oldManifestData.Entries))
14871503
}
1504+
if len(newManifestData.Entries) != len(actors.GetBuiltinActorsKeys()) {
1505+
return cid.Undef, xerrors.Errorf("incomplete new manifest with %d code CIDs", len(newManifestData.Entries))
1506+
}
14881507

14891508
// Maps prior version code CIDs to migration functions.
14901509
migrations := make(map[cid.Cid]cid.Cid)

0 commit comments

Comments
 (0)