Skip to content

Commit

Permalink
re-add the --no-migration flag
Browse files Browse the repository at this point in the history
  • Loading branch information
janezpodhostnik committed Jan 23, 2024
1 parent 9746b7f commit 759ba39
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
7 changes: 2 additions & 5 deletions cmd/util/cmd/execution-state-extract/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -153,11 +149,12 @@ func run(*cobra.Command, []string) {
}

err := extractExecutionState(
log.Logger,
flagExecutionStateDir,
stateCommitment,
flagOutputDir,
log.Logger,
flagNWorker,
!flagNoMigration,
)

if err != nil {
Expand Down
46 changes: 26 additions & 20 deletions cmd/util/cmd/execution-state-extract/execution_state_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit 759ba39

Please sign in to comment.