Skip to content

Commit

Permalink
check evm checks only presence of roots
Browse files Browse the repository at this point in the history
  • Loading branch information
uprendis committed Aug 19, 2022
1 parent fed5cb7 commit 7cba87c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions cmd/opera/launcher/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
10 changes: 7 additions & 3 deletions gossip/evmstore/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 7cba87c

Please sign in to comment.