@@ -2,7 +2,6 @@ package check_storage
2
2
3
3
import (
4
4
"context"
5
- "slices"
6
5
7
6
"github.com/rs/zerolog/log"
8
7
"github.com/spf13/cobra"
@@ -14,6 +13,7 @@ import (
14
13
"github.com/onflow/flow-go/cmd/util/ledger/reporters"
15
14
"github.com/onflow/flow-go/cmd/util/ledger/util"
16
15
"github.com/onflow/flow-go/cmd/util/ledger/util/registers"
16
+ "github.com/onflow/flow-go/fvm/evm/emulator/state"
17
17
"github.com/onflow/flow-go/fvm/systemcontracts"
18
18
"github.com/onflow/flow-go/ledger"
19
19
"github.com/onflow/flow-go/model/flow"
29
29
flagNWorker int
30
30
)
31
31
32
+ var (
33
+ evmAccount flow.Address
34
+ evmStorageIDKeys = []string {
35
+ state .AccountsStorageIDKey ,
36
+ state .CodesStorageIDKey ,
37
+ }
38
+ )
39
+
32
40
var Cmd = & cobra.Command {
33
41
Use : "check-storage" ,
34
42
Short : "Check storage health" ,
@@ -102,13 +110,8 @@ func run(*cobra.Command, []string) {
102
110
log .Fatal ().Msg ("--state-commitment must be provided when --state is provided" )
103
111
}
104
112
105
- // For now, skip EVM storage account since a different decoder is needed for decoding EVM registers.
106
-
107
- systemContracts := systemcontracts .SystemContractsForChain (chainID )
108
-
109
- acctsToSkip := []string {
110
- flow .AddressToRegisterOwner (systemContracts .EVMStorage .Address ),
111
- }
113
+ // Get EVM account by chain
114
+ evmAccount = systemcontracts .SystemContractsForChain (chainID ).EVMStorage .Address
112
115
113
116
// Create report in JSONL format
114
117
rw := reporters .NewReportFileWriterFactoryWithFormat (flagOutputDirectory , log .Logger , reporters .ReportFormatJSONL ).
@@ -161,13 +164,13 @@ func run(*cobra.Command, []string) {
161
164
len (payloads ),
162
165
)
163
166
164
- failedAccountAddresses , err := checkStorageHealth (registersByAccount , flagNWorker , rw , acctsToSkip )
167
+ failedAccountAddresses , err := checkStorageHealth (registersByAccount , flagNWorker , rw )
165
168
if err != nil {
166
169
log .Fatal ().Err (err ).Msg ("failed to check storage health" )
167
170
}
168
171
169
172
if len (failedAccountAddresses ) == 0 {
170
- log .Info ().Msgf ("All %d accounts are health " , accountCount )
173
+ log .Info ().Msgf ("All %d accounts are healthy " , accountCount )
171
174
return
172
175
}
173
176
@@ -188,7 +191,6 @@ func checkStorageHealth(
188
191
registersByAccount * registers.ByAccount ,
189
192
nWorkers int ,
190
193
rw reporters.ReportWriter ,
191
- acctsToSkip []string ,
192
194
) (failedAccountAddresses []string , err error ) {
193
195
194
196
accountCount := registersByAccount .AccountCount ()
@@ -211,10 +213,6 @@ func checkStorageHealth(
211
213
func (accountRegisters * registers.AccountRegisters ) error {
212
214
defer logAccount (1 )
213
215
214
- if slices .Contains (acctsToSkip , accountRegisters .Owner ()) {
215
- return nil
216
- }
217
-
218
216
accountStorageIssues := checkAccountStorageHealth (accountRegisters , nWorkers )
219
217
220
218
if len (accountStorageIssues ) > 0 {
@@ -281,9 +279,6 @@ func checkStorageHealth(
281
279
282
280
err = registersByAccount .ForEachAccount (
283
281
func (accountRegisters * registers.AccountRegisters ) error {
284
- if slices .Contains (acctsToSkip , accountRegisters .Owner ()) {
285
- return nil
286
- }
287
282
jobs <- job {accountRegisters : accountRegisters }
288
283
return nil
289
284
})
@@ -318,6 +313,10 @@ func checkAccountStorageHealth(accountRegisters *registers.AccountRegisters, nWo
318
313
}}
319
314
}
320
315
316
+ if isEVMAccount (address ) {
317
+ return checkEVMAccountStorageHealth (address , accountRegisters )
318
+ }
319
+
321
320
var issues []accountStorageIssue
322
321
323
322
// Check atree storage health
@@ -331,7 +330,7 @@ func checkAccountStorageHealth(accountRegisters *registers.AccountRegisters, nWo
331
330
issues ,
332
331
accountStorageIssue {
333
332
Address : address .Hex (),
334
- Kind : storageErrorKindString [atreeStorageErrorKind ],
333
+ Kind : storageErrorKindString [cadenceAtreeStorageErrorKind ],
335
334
Msg : err .Error (),
336
335
})
337
336
}
@@ -345,12 +344,14 @@ type storageErrorKind int
345
344
346
345
const (
347
346
otherErrorKind storageErrorKind = iota
348
- atreeStorageErrorKind
347
+ cadenceAtreeStorageErrorKind
348
+ evmAtreeStorageErrorKind
349
349
)
350
350
351
351
var storageErrorKindString = map [storageErrorKind ]string {
352
- otherErrorKind : "error_check_storage_failed" ,
353
- atreeStorageErrorKind : "error_atree_storage" ,
352
+ otherErrorKind : "error_check_storage_failed" ,
353
+ cadenceAtreeStorageErrorKind : "error_cadence_atree_storage" ,
354
+ evmAtreeStorageErrorKind : "error_evm_atree_storage" ,
354
355
}
355
356
356
357
type accountStorageIssue struct {
0 commit comments