@@ -39,7 +39,7 @@ func extractExecutionState(
39
39
runMigrations bool ,
40
40
outputPayloadFile string ,
41
41
exportPayloadsByAddresses []common.Address ,
42
- fixSlabWithBrokenReferences bool ,
42
+ fixSlabsWithBrokenReferences bool ,
43
43
) error {
44
44
45
45
log .Info ().Msg ("init WAL" )
@@ -90,7 +90,13 @@ func extractExecutionState(
90
90
<- compactor .Done ()
91
91
}()
92
92
93
- migrations := newMigrations (log , dir , nWorker , runMigrations )
93
+ migrations := newMigrations (
94
+ log ,
95
+ dir ,
96
+ nWorker ,
97
+ runMigrations ,
98
+ fixSlabsWithBrokenReferences ,
99
+ )
94
100
95
101
newState := ledger .State (targetHash )
96
102
@@ -214,7 +220,7 @@ func extractExecutionStateFromPayloads(
214
220
inputPayloadFile string ,
215
221
outputPayloadFile string ,
216
222
exportPayloadsByAddresses []common.Address ,
217
- fixSlabWithBrokenReferences bool ,
223
+ fixSlabsWithBrokenReferences bool ,
218
224
) error {
219
225
220
226
inputPayloadsFromPartialState , payloads , err := util .ReadPayloadFile (log , inputPayloadFile )
@@ -224,7 +230,13 @@ func extractExecutionStateFromPayloads(
224
230
225
231
log .Info ().Msgf ("read %d payloads" , len (payloads ))
226
232
227
- migrations := newMigrations (log , dir , nWorker , runMigrations )
233
+ migrations := newMigrations (
234
+ log ,
235
+ dir ,
236
+ nWorker ,
237
+ runMigrations ,
238
+ fixSlabsWithBrokenReferences ,
239
+ )
228
240
229
241
payloads , err = migratePayloads (log , payloads , migrations )
230
242
if err != nil {
@@ -353,32 +365,52 @@ func newMigrations(
353
365
dir string ,
354
366
nWorker int , // number of concurrent worker to migation payloads
355
367
runMigrations bool ,
368
+ fixSlabsWithBrokenReferences bool ,
356
369
) []ledger.Migration {
357
370
if runMigrations {
371
+
358
372
rwf := reporters .NewReportFileWriterFactory (dir , log )
359
373
360
- migrations := []ledger.Migration {
374
+ var accountBasedMigrations []migrators.AccountBasedMigration
375
+
376
+ if fixSlabsWithBrokenReferences {
377
+ accountBasedMigrations = append (
378
+ accountBasedMigrations ,
379
+ migrators .NewFixBrokenReferencesInSlabsMigration (
380
+ rwf ,
381
+ migrators .TestnetAccountsWithBrokenSlabReferences ,
382
+ ),
383
+ )
384
+ }
385
+
386
+ accountBasedMigrations = append (
387
+ accountBasedMigrations ,
388
+ migrators .NewFixBrokenReferencesInSlabsMigration (
389
+ rwf ,
390
+ migrators .TestnetAccountsWithBrokenSlabReferences ,
391
+ ),
392
+ migrators .NewAtreeRegisterMigrator (
393
+ rwf ,
394
+ flagValidateMigration ,
395
+ flagLogVerboseValidationError ,
396
+ flagContinueMigrationOnValidationError ,
397
+ flagCheckStorageHealthBeforeMigration ,
398
+ flagCheckStorageHealthAfterMigration ,
399
+ ),
400
+
401
+ & migrators.DeduplicateContractNamesMigration {},
402
+
403
+ // This will fix storage used discrepancies caused by the previous migrations
404
+ & migrators.AccountUsageMigrator {},
405
+ )
406
+
407
+ return []ledger.Migration {
361
408
migrators .CreateAccountBasedMigration (
362
409
log ,
363
410
nWorker ,
364
- []migrators.AccountBasedMigration {
365
- migrators .NewAtreeRegisterMigrator (
366
- rwf ,
367
- flagValidateMigration ,
368
- flagLogVerboseValidationError ,
369
- flagContinueMigrationOnValidationError ,
370
- flagCheckStorageHealthBeforeMigration ,
371
- flagCheckStorageHealthAfterMigration ,
372
- ),
373
-
374
- & migrators.DeduplicateContractNamesMigration {},
375
-
376
- // This will fix storage used discrepancies caused by the previous migrations
377
- & migrators.AccountUsageMigrator {},
378
- }),
411
+ accountBasedMigrations ,
412
+ ),
379
413
}
380
-
381
- return migrations
382
414
}
383
415
384
416
return nil
0 commit comments