diff --git a/cmd/opera/launcher/check.go b/cmd/opera/launcher/check.go index 03de24224..5322c58d0 100644 --- a/cmd/opera/launcher/check.go +++ b/cmd/opera/launcher/check.go @@ -27,12 +27,14 @@ func checkEvm(ctx *cli.Context) error { start, reported := time.Now(), time.Now() var prevPoint idx.Block + var prevIndex idx.Block checkBlocks := func(stateOK func(root common.Hash) (bool, error)) { var ( lastIdx = gdb.GetLatestBlockIndex() prevPointRootExist bool ) gdb.ForEachBlock(func(index idx.Block, block *inter.Block) { + prevIndex = index found, err := stateOK(common.Hash(block.Root)) if found != prevPointRootExist { if index > 0 && found { @@ -57,9 +59,9 @@ func checkEvm(ctx *cli.Context) error { }) } - if err := evms.CheckEvm(checkBlocks); err != nil { + if err := evms.CheckEvm(checkBlocks, true); err != nil { return err } - log.Info("EVM storage is verified", "last", prevPoint, "elapsed", common.PrettyDuration(time.Since(start))) + log.Info("EVM storage is verified", "last", prevIndex, "elapsed", common.PrettyDuration(time.Since(start))) return nil } diff --git a/gossip/evmstore/utils.go b/gossip/evmstore/utils.go index 5cace1c8c..5b9a65ce3 100644 --- a/gossip/evmstore/utils.go +++ b/gossip/evmstore/utils.go @@ -28,7 +28,7 @@ var ( emptyHash = common.Hash{} ) -func (s *Store) CheckEvm(forEachState func(func(root common.Hash) (found bool, err error))) error { +func (s *Store) CheckEvm(forEachState func(func(root common.Hash) (found bool, err error)), onlyRoots bool) error { log.Info("Checking every node hash") nodeIt := s.table.Evm.NewIterator(nil, nil) defer nodeIt.Release() @@ -68,7 +68,11 @@ func (s *Store) CheckEvm(forEachState func(func(root common.Hash) (found bool, e } } - log.Info("Checking presence of every node") + if onlyRoots { + log.Info("Checking presence of every root") + } else { + log.Info("Checking presence of every node") + } var ( visitedHashes = make([]common.Hash, 0, 1000000) visitedI = 0 @@ -88,7 +92,7 @@ func (s *Store) CheckEvm(forEachState func(func(root common.Hash) (found bool, e forEachState(func(root common.Hash) (found bool, err error) { stateTrie, err := s.EvmState.OpenTrie(root) found = stateTrie != nil && err == nil - if !found { + if !found || onlyRoots { return }