From 759ba39ad83b50ab144c794381ca89e6abf54c94 Mon Sep 17 00:00:00 2001 From: Janez Podhostnik Date: Tue, 23 Jan 2024 21:29:13 +0100 Subject: [PATCH] re-add the --no-migration flag --- cmd/util/cmd/execution-state-extract/cmd.go | 7 +-- .../execution_state_extract.go | 46 +++++++++++-------- .../execution_state_extract_test.go | 3 +- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/cmd/util/cmd/execution-state-extract/cmd.go b/cmd/util/cmd/execution-state-extract/cmd.go index b22ed8c5da3..55728b428a8 100644 --- a/cmd/util/cmd/execution-state-extract/cmd.go +++ b/cmd/util/cmd/execution-state-extract/cmd.go @@ -140,10 +140,6 @@ func run(*cobra.Command, []string) { log.Warn().Msgf("--no-report flag is deprecated") } - if flagNoMigration { - log.Warn().Msgf("--no-migration flag is deprecated") - } - if flagValidateMigration { log.Warn().Msgf("atree migration validation flag is enabled and will increase duration of migration") } @@ -153,11 +149,12 @@ func run(*cobra.Command, []string) { } err := extractExecutionState( + log.Logger, flagExecutionStateDir, stateCommitment, flagOutputDir, - log.Logger, flagNWorker, + !flagNoMigration, ) if err != nil { diff --git a/cmd/util/cmd/execution-state-extract/execution_state_extract.go b/cmd/util/cmd/execution-state-extract/execution_state_extract.go index f379bc2f9ec..90bcd70533d 100644 --- a/cmd/util/cmd/execution-state-extract/execution_state_extract.go +++ b/cmd/util/cmd/execution-state-extract/execution_state_extract.go @@ -28,11 +28,12 @@ func getStateCommitment(commits storage.Commits, blockHash flow.Identifier) (flo } func extractExecutionState( + log zerolog.Logger, dir string, targetHash flow.StateCommitment, outputDir string, - log zerolog.Logger, nWorker int, // number of concurrent worker to migation payloads + runMigrations bool, ) error { log.Info().Msg("init WAL") @@ -83,26 +84,31 @@ func extractExecutionState( <-compactor.Done() }() - rwf := reporters.NewReportFileWriterFactory(dir, log) - - var migrations = []ledger.Migration{ - migrators.CreateAccountBasedMigration( - log, - nWorker, - []migrators.AccountBasedMigration{ - migrators.NewAtreeRegisterMigrator( - rwf, - flagValidateMigration, - flagLogVerboseValidationError, - ), - - &migrators.DeduplicateContractNamesMigration{}, - - // This will fix storage used discrepancies caused by the - // DeduplicateContractNamesMigration. - &migrators.AccountUsageMigrator{}, - }), + var migrations []ledger.Migration + + if runMigrations { + rwf := reporters.NewReportFileWriterFactory(dir, log) + + migrations = []ledger.Migration{ + migrators.CreateAccountBasedMigration( + log, + nWorker, + []migrators.AccountBasedMigration{ + migrators.NewAtreeRegisterMigrator( + rwf, + flagValidateMigration, + flagLogVerboseValidationError, + ), + + &migrators.DeduplicateContractNamesMigration{}, + + // This will fix storage used discrepancies caused by the + // DeduplicateContractNamesMigration. + &migrators.AccountUsageMigrator{}, + }), + } } + newState := ledger.State(targetHash) // migrate the trie if there are migrations diff --git a/cmd/util/cmd/execution-state-extract/execution_state_extract_test.go b/cmd/util/cmd/execution-state-extract/execution_state_extract_test.go index 018c5474c66..2f91ea7d603 100644 --- a/cmd/util/cmd/execution-state-extract/execution_state_extract_test.go +++ b/cmd/util/cmd/execution-state-extract/execution_state_extract_test.go @@ -60,11 +60,12 @@ func TestExtractExecutionState(t *testing.T) { t.Run("empty WAL doesn't find anything", func(t *testing.T) { withDirs(t, func(datadir, execdir, outdir string) { err := extractExecutionState( + zerolog.Nop(), execdir, unittest.StateCommitmentFixture(), outdir, - zerolog.Nop(), 10, + false, ) require.Error(t, err) })