Skip to content

Commit f9798b7

Browse files
committed
integrate new migration
1 parent a792258 commit f9798b7

File tree

3 files changed

+60
-29
lines changed

3 files changed

+60
-29
lines changed

cmd/util/cmd/execution-state-extract/cmd.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var (
3939
flagInputPayloadFileName string
4040
flagOutputPayloadFileName string
4141
flagOutputPayloadByAddresses string
42-
flagFixSlabWithBrokenReferences bool
42+
flagFixSlabsWithBrokenReferences bool
4343
)
4444

4545
var Cmd = &cobra.Command{
@@ -124,7 +124,7 @@ func init() {
124124
"extract payloads of addresses (comma separated hex-encoded addresses) to file specified by output-payload-filename",
125125
)
126126

127-
Cmd.Flags().BoolVar(&flagFixSlabWithBrokenReferences, "fix-testnet-slabs-with-broken-references", false,
127+
Cmd.Flags().BoolVar(&flagFixSlabsWithBrokenReferences, "fix-testnet-slabs-with-broken-references", false,
128128
"fix slabs with broken references in testnet")
129129
}
130130

@@ -303,9 +303,8 @@ func run(*cobra.Command, []string) {
303303

304304
log.Info().Msgf("state extraction plan: %s, %s", inputMsg, outputMsg)
305305

306-
307306
chainID := flow.ChainID(flagChain)
308-
fixSlabWithBrokenReferences := chainID == flow.Testnet && flagFixSlabWithBrokenReferences
307+
fixSlabsWithBrokenReferences := chainID == flow.Testnet && flagFixSlabsWithBrokenReferences
309308

310309
var err error
311310
if len(flagInputPayloadFileName) > 0 {
@@ -318,7 +317,7 @@ func run(*cobra.Command, []string) {
318317
flagInputPayloadFileName,
319318
flagOutputPayloadFileName,
320319
exportedAddresses,
321-
fixSlabWithBrokenReferences,
320+
fixSlabsWithBrokenReferences,
322321
)
323322
} else {
324323
err = extractExecutionState(
@@ -330,7 +329,7 @@ func run(*cobra.Command, []string) {
330329
!flagNoMigration,
331330
flagOutputPayloadFileName,
332331
exportedAddresses,
333-
fixSlabWithBrokenReferences,
332+
fixSlabsWithBrokenReferences,
334333
)
335334
}
336335

cmd/util/cmd/execution-state-extract/execution_state_extract.go

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func extractExecutionState(
3939
runMigrations bool,
4040
outputPayloadFile string,
4141
exportPayloadsByAddresses []common.Address,
42-
fixSlabWithBrokenReferences bool,
42+
fixSlabsWithBrokenReferences bool,
4343
) error {
4444

4545
log.Info().Msg("init WAL")
@@ -90,7 +90,13 @@ func extractExecutionState(
9090
<-compactor.Done()
9191
}()
9292

93-
migrations := newMigrations(log, dir, nWorker, runMigrations)
93+
migrations := newMigrations(
94+
log,
95+
dir,
96+
nWorker,
97+
runMigrations,
98+
fixSlabsWithBrokenReferences,
99+
)
94100

95101
newState := ledger.State(targetHash)
96102

@@ -214,7 +220,7 @@ func extractExecutionStateFromPayloads(
214220
inputPayloadFile string,
215221
outputPayloadFile string,
216222
exportPayloadsByAddresses []common.Address,
217-
fixSlabWithBrokenReferences bool,
223+
fixSlabsWithBrokenReferences bool,
218224
) error {
219225

220226
inputPayloadsFromPartialState, payloads, err := util.ReadPayloadFile(log, inputPayloadFile)
@@ -224,7 +230,13 @@ func extractExecutionStateFromPayloads(
224230

225231
log.Info().Msgf("read %d payloads", len(payloads))
226232

227-
migrations := newMigrations(log, dir, nWorker, runMigrations)
233+
migrations := newMigrations(
234+
log,
235+
dir,
236+
nWorker,
237+
runMigrations,
238+
fixSlabsWithBrokenReferences,
239+
)
228240

229241
payloads, err = migratePayloads(log, payloads, migrations)
230242
if err != nil {
@@ -353,32 +365,52 @@ func newMigrations(
353365
dir string,
354366
nWorker int, // number of concurrent worker to migation payloads
355367
runMigrations bool,
368+
fixSlabsWithBrokenReferences bool,
356369
) []ledger.Migration {
357370
if runMigrations {
371+
358372
rwf := reporters.NewReportFileWriterFactory(dir, log)
359373

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{
361408
migrators.CreateAccountBasedMigration(
362409
log,
363410
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+
),
379413
}
380-
381-
return migrations
382414
}
383415

384416
return nil

cmd/util/ledger/migrations/account_based_migration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func MigrateGroupConcurrently(
300300
return migrated, nil
301301
}
302302

303-
var testnetAccountsWithBrokenSlabReferences = func() map[common.Address]struct{} {
303+
var TestnetAccountsWithBrokenSlabReferences = func() map[common.Address]struct{} {
304304
testnetAddresses := map[common.Address]struct{}{
305305
mustHexToAddress("434a1f199a7ae3ba"): {},
306306
mustHexToAddress("454c9991c2b8d947"): {},

0 commit comments

Comments
 (0)