Skip to content

Commit

Permalink
Make pre-migration optional
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Nov 16, 2022
1 parent c585ce6 commit 3c50d27
Showing 1 changed file with 39 additions and 34 deletions.
73 changes: 39 additions & 34 deletions cmd/lotus-shed/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ var migrationsCmd = &cli.Command{
Name: "repo",
Value: "~/.lotus",
},
&cli.BoolFlag{
Name: "pre-migration",
},
&cli.BoolFlag{
Name: "check-invariants",
},
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3c50d27

Please sign in to comment.