@@ -53,6 +53,9 @@ var migrationsCmd = &cli.Command{
53
53
Name : "repo" ,
54
54
Value : "~/.lotus" ,
55
55
},
56
+ & cli.BoolFlag {
57
+ Name : "skip-pre-migration" ,
58
+ },
56
59
& cli.BoolFlag {
57
60
Name : "check-invariants" ,
58
61
},
@@ -119,63 +122,66 @@ var migrationsCmd = &cli.Command{
119
122
return err
120
123
}
121
124
122
- ts1 , err := cs .GetTipsetByHeight (ctx , blk .Height - 240 , migrationTs , false )
123
- if err != nil {
124
- return err
125
- }
126
-
127
125
startTime := time .Now ()
128
126
129
- err = filcns .PreUpgradeActorsV9 (ctx , sm , cache , ts1 . ParentState (), ts1 . Height () - 1 , ts1 )
127
+ newCid2 , err : = filcns .UpgradeActorsV9 (ctx , sm , nv15 . NewMemMigrationCache (), nil , blk . ParentStateRoot , blk . Height - 1 , migrationTs )
130
128
if err != nil {
131
129
return err
132
130
}
133
131
134
- preMigration1Time := time .Since (startTime )
132
+ uncachedMigrationTime := time .Since (startTime )
135
133
136
- ts2 , err := cs . GetTipsetByHeight ( ctx , blk .Height - 15 , migrationTs , false )
137
- if err != nil {
138
- return err
139
- }
134
+ fmt . Println ( "migration height " , blk .Height - 1 )
135
+ fmt . Println ( "old cid " , blk . ParentStateRoot )
136
+ fmt . Println ( "new cid " , newCid2 )
137
+ fmt . Println ( "completed round actual (without cache), took " , uncachedMigrationTime )
140
138
141
- startTime = time .Now ()
139
+ if ! cctx .IsSet ("skip-pre-migration" ) {
140
+ startTime = time .Now ()
142
141
143
- err = filcns . PreUpgradeActorsV9 (ctx , sm , cache , ts2 . ParentState (), ts2 . Height () - 1 , ts2 )
144
- if err != nil {
145
- return err
146
- }
142
+ ts1 , err := cs . GetTipsetByHeight (ctx , blk . Height - 240 , migrationTs , false )
143
+ if err != nil {
144
+ return err
145
+ }
147
146
148
- preMigration2Time := time .Since (startTime )
147
+ err = filcns .PreUpgradeActorsV9 (ctx , sm , cache , ts1 .ParentState (), ts1 .Height ()- 1 , ts1 )
148
+ if err != nil {
149
+ return err
150
+ }
149
151
150
- startTime = time .Now ( )
152
+ preMigration1Time : = time .Since ( startTime )
151
153
152
- newCid1 , err := filcns . UpgradeActorsV9 (ctx , sm , cache , nil , blk .ParentStateRoot , blk . Height - 1 , migrationTs )
153
- if err != nil {
154
- return err
155
- }
154
+ ts2 , err := cs . GetTipsetByHeight (ctx , blk .Height - 15 , migrationTs , false )
155
+ if err != nil {
156
+ return err
157
+ }
156
158
157
- cachedMigrationTime : = time .Since ( startTime )
159
+ startTime = time .Now ( )
158
160
159
- startTime = time .Now ()
161
+ err = filcns .PreUpgradeActorsV9 (ctx , sm , cache , ts2 .ParentState (), ts2 .Height ()- 1 , ts2 )
162
+ if err != nil {
163
+ return err
164
+ }
160
165
161
- newCid2 , err := filcns .UpgradeActorsV9 (ctx , sm , nv15 .NewMemMigrationCache (), nil , blk .ParentStateRoot , blk .Height - 1 , migrationTs )
162
- if err != nil {
163
- return err
164
- }
166
+ preMigration2Time := time .Since (startTime )
165
167
166
- uncachedMigrationTime : = time .Since ( startTime )
168
+ startTime = time .Now ( )
167
169
168
- if newCid1 != newCid2 {
169
- return xerrors . Errorf ( "got different results with and without the cache: %s, %s" , newCid1 ,
170
- newCid2 )
171
- }
170
+ newCid1 , err := filcns . UpgradeActorsV9 ( ctx , sm , cache , nil , blk . ParentStateRoot , blk . Height - 1 , migrationTs )
171
+ if err != nil {
172
+ return err
173
+ }
172
174
173
- fmt .Println ("migration height " , blk .Height - 1 )
174
- fmt .Println ("new cid " , newCid2 )
175
- fmt .Println ("completed premigration 1, took " , preMigration1Time )
176
- fmt .Println ("completed premigration 2, took " , preMigration2Time )
177
- fmt .Println ("completed round actual (with cache), took " , cachedMigrationTime )
178
- fmt .Println ("completed round actual (without cache), took " , uncachedMigrationTime )
175
+ cachedMigrationTime := time .Since (startTime )
176
+
177
+ if newCid1 != newCid2 {
178
+ return xerrors .Errorf ("got different results with and without the cache: %s, %s" , newCid1 ,
179
+ newCid2 )
180
+ }
181
+ fmt .Println ("completed premigration 1, took " , preMigration1Time )
182
+ fmt .Println ("completed premigration 2, took " , preMigration2Time )
183
+ fmt .Println ("completed round actual (with cache), took " , cachedMigrationTime )
184
+ }
179
185
180
186
if cctx .Bool ("check-invariants" ) {
181
187
err = checkMigrationInvariants (ctx , blk .ParentStateRoot , newCid2 , bs , blk .Height - 1 )
0 commit comments