From 8604db60769ae49bed28b0e8af7f99d8c5bef26a Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:18:56 -0500 Subject: [PATCH] Skip EVM storage account in check-storage cmd This commit skips EVM storage account during atree storage health check because EVM registers require a different decoder. Cadence-Atree decoder cannot decode EVM registers. Support for checking EVM registers can be added later. --- cmd/util/cmd/check-storage/cmd.go | 35 ++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/cmd/util/cmd/check-storage/cmd.go b/cmd/util/cmd/check-storage/cmd.go index ea44fa485df..19cadb85694 100644 --- a/cmd/util/cmd/check-storage/cmd.go +++ b/cmd/util/cmd/check-storage/cmd.go @@ -2,6 +2,7 @@ package check_storage import ( "context" + "slices" "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -14,7 +15,9 @@ import ( "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" + "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/ledger" + "github.com/onflow/flow-go/model/flow" moduleUtil "github.com/onflow/flow-go/module/util" ) @@ -23,6 +26,7 @@ var ( flagState string flagStateCommitment string flagOutputDirectory string + flagChain string flagNWorker int ) @@ -74,10 +78,22 @@ func init() { 10, "number of workers to use", ) + + Cmd.Flags().StringVar( + &flagChain, + "chain", + "", + "Chain name", + ) + _ = Cmd.MarkFlagRequired("chain") } func run(*cobra.Command, []string) { + chainID := flow.ChainID(flagChain) + // Validate chain ID + _ = chainID.Chain() + if flagPayloads == "" && flagState == "" { log.Fatal().Msg("Either --payloads or --state must be provided") } else if flagPayloads != "" && flagState != "" { @@ -87,6 +103,14 @@ func run(*cobra.Command, []string) { log.Fatal().Msg("--state-commitment must be provided when --state is provided") } + // For now, skip EVM storage account since a different decoder is needed for decoding EVM registers. + + systemContracts := systemcontracts.SystemContractsForChain(chainID) + + acctsToSkip := []string{ + flow.AddressToRegisterOwner(systemContracts.EVMStorage.Address), + } + // Create report in JSONL format rw := reporters.NewReportFileWriterFactoryWithFormat(flagOutputDirectory, log.Logger, reporters.ReportFormatJSONL). ReportWriter(ReporterName) @@ -138,7 +162,7 @@ func run(*cobra.Command, []string) { len(payloads), ) - failedAccountAddresses, err := checkStorageHealth(registersByAccount, flagNWorker, rw) + failedAccountAddresses, err := checkStorageHealth(registersByAccount, flagNWorker, rw, acctsToSkip) if err != nil { log.Fatal().Err(err).Msg("failed to check storage health") } @@ -165,6 +189,7 @@ func checkStorageHealth( registersByAccount *registers.ByAccount, nWorkers int, rw reporters.ReportWriter, + acctsToSkip []string, ) (failedAccountAddresses []string, err error) { accountCount := registersByAccount.AccountCount() @@ -185,6 +210,12 @@ func checkStorageHealth( // Skip goroutine to avoid overhead err = registersByAccount.ForEachAccount( func(accountRegisters *registers.AccountRegisters) error { + defer logAccount(1) + + if slices.Contains(acctsToSkip, accountRegisters.Owner()) { + return nil + } + accountStorageIssues := checkAccountStorageHealth(accountRegisters, nWorkers) if len(accountStorageIssues) > 0 { @@ -195,8 +226,6 @@ func checkStorageHealth( } } - logAccount(1) - return nil })