Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atree storage migration #4633

Merged
merged 98 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
b86fcd7
Atree migration initial commit
janezpodhostnik Aug 16, 2023
6bc49d3
atree migration remove contract loading
janezpodhostnik Sep 1, 2023
bd80b6f
log missing keys correctly
janezpodhostnik Sep 1, 2023
abba33f
retrieve atree values before checking storage
janezpodhostnik Sep 6, 2023
43a19e3
atree migration cleanup
janezpodhostnik Sep 8, 2023
a076dca
migrations, change account grouping
janezpodhostnik Sep 12, 2023
abe6623
bugfix and skipping known problematic accounts
janezpodhostnik Sep 13, 2023
345568b
add specific account dump
janezpodhostnik Sep 13, 2023
f93f495
logging change
janezpodhostnik Sep 14, 2023
088e02c
sorting change and storage used verification
janezpodhostnik Sep 15, 2023
94e9477
storage used migration logs update
janezpodhostnik Sep 15, 2023
2a63c65
storage used migration fix
janezpodhostnik Sep 15, 2023
b8aa210
add cadence value validation
janezpodhostnik Sep 19, 2023
e8fc9fe
fix storage used migration
janezpodhostnik Sep 19, 2023
ad5c730
fix
janezpodhostnik Sep 19, 2023
4591aa9
fix setting storage on value removal
janezpodhostnik Sep 20, 2023
574a0d6
handle account hashs error better
janezpodhostnik Sep 20, 2023
bd1c2cc
add output for a few accounts
janezpodhostnik Sep 20, 2023
17d537d
migrate empty domain storage maps
janezpodhostnik Sep 21, 2023
1db0a2c
add more metrics to migration
janezpodhostnik Sep 21, 2023
3a6100f
Skip accounts from other migrations as weel
janezpodhostnik Sep 21, 2023
b0498c6
temporarily disable migration validation
janezpodhostnik Sep 22, 2023
510b19c
atree migration test big account
janezpodhostnik Sep 22, 2023
05e5241
add validation back
janezpodhostnik Sep 22, 2023
3031e32
parallel verification test
janezpodhostnik Sep 22, 2023
2c41508
hashing fix
janezpodhostnik Sep 25, 2023
49def5a
collection decompose fix
janezpodhostnik Sep 25, 2023
cff2237
fix data validation concurency
janezpodhostnik Sep 26, 2023
b8e1852
move creating storage maps inside workers
janezpodhostnik Sep 26, 2023
9447b44
validation fix
janezpodhostnik Sep 27, 2023
08b55ad
fix missing interpreter
janezpodhostnik Sep 27, 2023
4f9a04a
fix rebase
janezpodhostnik Sep 27, 2023
2814581
add a lot of loging to migration validation
janezpodhostnik Sep 27, 2023
7f7485e
more logging
janezpodhostnik Sep 27, 2023
5c02a9c
fix migration concurency
janezpodhostnik Sep 28, 2023
fe9eed2
fix log progress
janezpodhostnik Sep 28, 2023
159dab5
fix missing close channel
janezpodhostnik Sep 28, 2023
792b603
allocate storage index fix
janezpodhostnik Sep 28, 2023
e80fca0
fix locking on allocate storage index
janezpodhostnik Sep 29, 2023
3150c7f
fix interpreter use
janezpodhostnik Sep 29, 2023
b602cb3
fix interpreter use
janezpodhostnik Sep 29, 2023
6131655
add better error reporting
janezpodhostnik Sep 29, 2023
0049e7f
better errors
janezpodhostnik Oct 2, 2023
1d318b7
even more errors
janezpodhostnik Oct 2, 2023
bfdfb0c
print stack on recover
janezpodhostnik Oct 2, 2023
3a74a09
disable InvalidatedResourceValidationEnabled
janezpodhostnik Oct 3, 2023
3bf2809
setKey -> insert
janezpodhostnik Oct 4, 2023
a61e0fa
change getKey to Get
janezpodhostnik Oct 4, 2023
1cda365
SetKey -> insert
janezpodhostnik Oct 4, 2023
ca7798a
print value type
janezpodhostnik Oct 4, 2023
acaf533
unseafe dict insert
janezpodhostnik Oct 9, 2023
af90ea1
remove print
janezpodhostnik Oct 9, 2023
0ec582d
skip saving cricketmomentshardedcollection
janezpodhostnik Oct 9, 2023
fa320ae
copy untouched cricket registers
janezpodhostnik Oct 10, 2023
ded242a
separate remove of cricket moments
janezpodhostnik Oct 10, 2023
83acf67
add logging
janezpodhostnik Oct 11, 2023
ee4104c
commit child interpreters
janezpodhostnik Oct 11, 2023
efe96d6
iteration 1021 of trying to make migration faster and still correct
janezpodhostnik Oct 12, 2023
ab1b6c7
fix
janezpodhostnik Oct 12, 2023
3848d24
fix 2
janezpodhostnik Oct 12, 2023
126c5ec
unsafe remove and additional metrics
janezpodhostnik Oct 13, 2023
79abcce
cadence optimisations
janezpodhostnik Oct 16, 2023
a6842de
change cadence
janezpodhostnik Oct 16, 2023
41e3d78
redesign storage index retrieval
janezpodhostnik Oct 17, 2023
4bea75b
Merge branch 'master' into janez/atree-migration
janezpodhostnik Oct 17, 2023
6fe06d5
Merge fix
janezpodhostnik Oct 17, 2023
12df741
switch back to just remove
janezpodhostnik Oct 17, 2023
306fad8
separate remove
janezpodhostnik Oct 18, 2023
458edc8
cleanup
janezpodhostnik Oct 18, 2023
677ce09
logging
janezpodhostnik Oct 19, 2023
132ab6d
change channel closing on error
janezpodhostnik Oct 19, 2023
ca10024
reduce error to log
janezpodhostnik Oct 19, 2023
7357571
fix state key detection
janezpodhostnik Oct 19, 2023
052054e
fix account migration
janezpodhostnik Oct 19, 2023
a21c1f2
deduplicate contract names
janezpodhostnik Oct 19, 2023
866346a
new test, just cricket moments
janezpodhostnik Oct 19, 2023
704f3d1
check it this fixes the data issue
janezpodhostnik Oct 20, 2023
613febe
unsafe insert
janezpodhostnik Oct 20, 2023
2c04d69
logging for hashing
janezpodhostnik Oct 21, 2023
2f422d0
deterministic recursive string
janezpodhostnik Oct 23, 2023
6dd5d5a
try without special casing cricketMoments
janezpodhostnik Oct 26, 2023
146e212
removeremove skip for other accounts
janezpodhostnik Oct 27, 2023
017c570
Merge branch 'master' into janez/atree-migration
janezpodhostnik Dec 8, 2023
cec5f30
merge fix
janezpodhostnik Dec 8, 2023
da62ec6
Merge branch 'janez/migration-infrastructure' into janez/atree-migration
janezpodhostnik Dec 13, 2023
6059bed
Merge branch 'janez/deduplicate-contract-names' into janez/atree-migr…
janezpodhostnik Jan 2, 2024
409b0b3
add close metthod to validation migration
janezpodhostnik Jan 2, 2024
07f8723
remove one account usage migrator
janezpodhostnik Jan 3, 2024
074e115
Validate migrated Cadence values using Equal()
fxamacker Jan 5, 2024
706b5a5
Add flag for verbose validation error logging
fxamacker Jan 9, 2024
d56df32
Check composite field count during validation
fxamacker Jan 9, 2024
00cdc35
Merge pull request #5204 from onflow/fxamacker/atree-migration-cadenc…
fxamacker Jan 9, 2024
3374a26
review fixes
janezpodhostnik Jan 16, 2024
a5275dd
remove cricket moments references from atree migration
janezpodhostnik Jan 16, 2024
8d74789
Merge pull request #5242 from onflow/janez/atree-migration-cleanup
janezpodhostnik Jan 18, 2024
d2d88f2
Increase log level for cadence data validation
janezpodhostnik Jan 23, 2024
9746b7f
state payload is not found is an error
janezpodhostnik Jan 23, 2024
759ba39
re-add the --no-migration flag
janezpodhostnik Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions cmd/util/cmd/execution-state-extract/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ import (
)

var (
flagExecutionStateDir string
flagOutputDir string
flagBlockHash string
flagStateCommitment string
flagDatadir string
flagChain string
flagNoMigration bool
flagNoReport bool
flagNWorker int
flagExecutionStateDir string
flagOutputDir string
flagBlockHash string
flagStateCommitment string
flagDatadir string
flagChain string
flagNWorker int
flagNoMigration bool
flagNoReport bool
flagValidateMigration bool
flagLogVerboseValidationError bool
)

var Cmd = &cobra.Command{
Expand Down Expand Up @@ -59,6 +61,13 @@ func init() {
"don't report the state")

Cmd.Flags().IntVar(&flagNWorker, "n-migrate-worker", 10, "number of workers to migrate payload concurrently")

Cmd.Flags().BoolVar(&flagValidateMigration, "validate", false,
"validate migrated Cadence values (atree migration)")

Cmd.Flags().BoolVar(&flagLogVerboseValidationError, "log-verbose-validation-error", false,
"log entire Cadence values on validation error (atree migration)")

}

func run(*cobra.Command, []string) {
Expand Down Expand Up @@ -131,16 +140,21 @@ 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")
}

if flagLogVerboseValidationError {
log.Warn().Msgf("atree migration has verbose validation error logging enabled which may increase size of log")
}

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

if err != nil {
Expand Down
28 changes: 27 additions & 1 deletion cmd/util/cmd/execution-state-extract/execution_state_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/rs/zerolog"
"go.uber.org/atomic"

migrators "github.com/onflow/flow-go/cmd/util/ledger/migrations"
"github.com/onflow/flow-go/cmd/util/ledger/reporters"
"github.com/onflow/flow-go/ledger"
"github.com/onflow/flow-go/ledger/common/hash"
Expand All @@ -27,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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhangchiqing as discussed, re-adding this

) error {

log.Info().Msg("init WAL")
Expand Down Expand Up @@ -83,6 +85,30 @@ func extractExecutionState(
}()

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
Loading
Loading