From 3c50d27c073bd524d0fcd9e23b38069f248cf9ea Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Mon, 14 Nov 2022 16:46:45 -0500 Subject: [PATCH] Make pre-migration optional --- cmd/lotus-shed/migrations.go | 73 +++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/cmd/lotus-shed/migrations.go b/cmd/lotus-shed/migrations.go index 415faa16d5f..08420cae827 100644 --- a/cmd/lotus-shed/migrations.go +++ b/cmd/lotus-shed/migrations.go @@ -53,6 +53,9 @@ var migrationsCmd = &cli.Command{ Name: "repo", Value: "~/.lotus", }, + &cli.BoolFlag{ + Name: "pre-migration", + }, &cli.BoolFlag{ Name: "check-invariants", }, @@ -126,56 +129,58 @@ var migrationsCmd = &cli.Command{ startTime := time.Now() - err = filcns.PreUpgradeActorsV9(ctx, sm, cache, ts1.ParentState(), ts1.Height()-1, ts1) + newCid2, err := filcns.UpgradeActorsV9(ctx, sm, nv15.NewMemMigrationCache(), nil, blk.ParentStateRoot, blk.Height-1, migrationTs) if err != nil { return err } - preMigration1Time := time.Since(startTime) + uncachedMigrationTime := time.Since(startTime) - ts2, err := cs.GetTipsetByHeight(ctx, blk.Height-15, migrationTs, false) - if err != nil { - return err - } + fmt.Println("migration height ", blk.Height-1) + fmt.Println("new cid ", newCid2) + fmt.Println("completed round actual (without cache), took ", uncachedMigrationTime) - startTime = time.Now() + if cctx.IsSet("pre-migration") { + startTime = time.Now() - err = filcns.PreUpgradeActorsV9(ctx, sm, cache, ts2.ParentState(), ts2.Height()-1, ts2) - if err != nil { - return err - } + err = filcns.PreUpgradeActorsV9(ctx, sm, cache, ts1.ParentState(), ts1.Height()-1, ts1) + if err != nil { + return err + } - preMigration2Time := time.Since(startTime) + preMigration1Time := time.Since(startTime) - startTime = time.Now() + ts2, err := cs.GetTipsetByHeight(ctx, blk.Height-15, migrationTs, false) + if err != nil { + return err + } - newCid1, err := filcns.UpgradeActorsV9(ctx, sm, cache, nil, blk.ParentStateRoot, blk.Height-1, migrationTs) - if err != nil { - return err - } + startTime = time.Now() - cachedMigrationTime := time.Since(startTime) + err = filcns.PreUpgradeActorsV9(ctx, sm, cache, ts2.ParentState(), ts2.Height()-1, ts2) + if err != nil { + return err + } - startTime = time.Now() + preMigration2Time := time.Since(startTime) - newCid2, err := filcns.UpgradeActorsV9(ctx, sm, nv15.NewMemMigrationCache(), nil, blk.ParentStateRoot, blk.Height-1, migrationTs) - if err != nil { - return err - } + startTime = time.Now() - uncachedMigrationTime := time.Since(startTime) + newCid1, err := filcns.UpgradeActorsV9(ctx, sm, cache, nil, blk.ParentStateRoot, blk.Height-1, migrationTs) + if err != nil { + return err + } - if newCid1 != newCid2 { - return xerrors.Errorf("got different results with and without the cache: %s, %s", newCid1, - newCid2) - } + cachedMigrationTime := time.Since(startTime) - fmt.Println("migration height ", blk.Height-1) - fmt.Println("new cid ", newCid2) - fmt.Println("completed premigration 1, took ", preMigration1Time) - fmt.Println("completed premigration 2, took ", preMigration2Time) - fmt.Println("completed round actual (with cache), took ", cachedMigrationTime) - fmt.Println("completed round actual (without cache), took ", uncachedMigrationTime) + if newCid1 != newCid2 { + return xerrors.Errorf("got different results with and without the cache: %s, %s", newCid1, + newCid2) + } + fmt.Println("completed premigration 1, took ", preMigration1Time) + fmt.Println("completed premigration 2, took ", preMigration2Time) + fmt.Println("completed round actual (with cache), took ", cachedMigrationTime) + } if cctx.Bool("check-invariants") { err = checkMigrationInvariants(ctx, blk.ParentStateRoot, newCid2, bs, blk.Height-1)