From 8a1fa4443318b819793cdc6c8da3fe31f6620165 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Mon, 26 Aug 2024 19:21:09 -0500 Subject: [PATCH] Include the cap_tag domain in check-storage Currently, the util program's check-storage command is missing the cap_tag domain. cap_tag domain was created on testnet and needs to be included in storage health check to avoid false alarm of unreferenced slabs. This commit includes the cap_tag domain to check-storage command. --- cmd/util/cmd/check-storage/cmd.go | 6 ++++-- cmd/util/ledger/util/util.go | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cmd/util/cmd/check-storage/cmd.go b/cmd/util/cmd/check-storage/cmd.go index 19cadb85694..5727d7a51d5 100644 --- a/cmd/util/cmd/check-storage/cmd.go +++ b/cmd/util/cmd/check-storage/cmd.go @@ -11,7 +11,6 @@ import ( "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/runtime/common" - "github.com/onflow/flow-go/cmd/util/ledger/migrations" "github.com/onflow/flow-go/cmd/util/ledger/reporters" "github.com/onflow/flow-go/cmd/util/ledger/util" "github.com/onflow/flow-go/cmd/util/ledger/util/registers" @@ -282,6 +281,9 @@ func checkStorageHealth( err = registersByAccount.ForEachAccount( func(accountRegisters *registers.AccountRegisters) error { + if slices.Contains(acctsToSkip, accountRegisters.Owner()) { + return nil + } jobs <- job{accountRegisters: accountRegisters} return nil }) @@ -323,7 +325,7 @@ func checkAccountStorageHealth(accountRegisters *registers.AccountRegisters, nWo ledger := ®isters.ReadOnlyLedger{Registers: accountRegisters} storage := runtime.NewStorage(ledger, nil) - err = util.CheckStorageHealth(address, storage, accountRegisters, migrations.AllStorageMapDomains, nWorkers) + err = util.CheckStorageHealth(address, storage, accountRegisters, util.StorageMapDomains, nWorkers) if err != nil { issues = append( issues, diff --git a/cmd/util/ledger/util/util.go b/cmd/util/ledger/util/util.go index a3d2073d597..148aae93432 100644 --- a/cmd/util/ledger/util/util.go +++ b/cmd/util/ledger/util/util.go @@ -9,7 +9,9 @@ import ( "strings" "github.com/onflow/atree" + "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/runtime/common" + "github.com/onflow/cadence/runtime/stdlib" "github.com/onflow/flow-go/fvm/environment" "github.com/onflow/flow-go/ledger" @@ -245,3 +247,15 @@ func (p *PayloadsLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error panic("AllocateSlabIndex not expected to be called") } + +var StorageMapDomains = []string{ + common.PathDomainStorage.Identifier(), + common.PathDomainPrivate.Identifier(), + common.PathDomainPublic.Identifier(), + runtime.StorageDomainContract, + stdlib.InboxStorageDomain, + stdlib.CapabilityControllerStorageDomain, + stdlib.CapabilityControllerTagStorageDomain, + stdlib.PathCapabilityStorageDomain, + stdlib.AccountCapabilityStorageDomain, +}