Skip to content

Commit

Permalink
Merge pull request #5756 from onflow/bastian/use-existing-storage-hea…
Browse files Browse the repository at this point in the history
…lth-check
  • Loading branch information
turbolent authored Apr 23, 2024
2 parents dfb68b2 + abe5794 commit 0a1e8f7
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions cmd/util/ledger/migrations/cadence_values_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"errors"

"github.com/onflow/atree"
"github.com/onflow/cadence/migrations"
"github.com/onflow/cadence/migrations/capcons"
"github.com/onflow/cadence/migrations/entitlements"
Expand Down Expand Up @@ -122,38 +121,7 @@ func (m *CadenceBaseMigrator) MigrateAccount(
var storageHealthErrorBefore error
if m.checkStorageHealthBeforeMigration {

// TODO: use checkStorageHealth

// Retrieve all slabs before migration.
for _, payload := range oldPayloads {
registerID, _, err := convert.PayloadToRegister(payload)
if err != nil {
return nil, fmt.Errorf("failed to convert payload to register: %w", err)
}

if !registerID.IsSlabIndex() {
continue
}

// Convert the register ID to a storage ID.
storageID := atree.StorageID{
Address: atree.Address([]byte(registerID.Owner)),
}
copy(storageID.Index[:], registerID.Key[1:])

// Retrieve the slab.
_, _, err = storage.Retrieve(storageID)
if err != nil {
return nil, fmt.Errorf("failed to retrieve slab %s: %w", storageID, err)
}
}

// Load storage map.
for _, domain := range allStorageMapDomains {
_ = storage.GetStorageMap(address, domain, false)
}

storageHealthErrorBefore = storage.CheckHealth()
storageHealthErrorBefore = checkStorageHealth(address, storage, oldPayloads)
if storageHealthErrorBefore != nil {
m.log.Warn().
Err(storageHealthErrorBefore).
Expand Down

0 comments on commit 0a1e8f7

Please sign in to comment.